Fixes memory leak in EN_addnode() (#455)

* Fixing memory leak in EN_addnode()

* Separating test_net_builder from test_toolkit

Making test_net_builder a standalone test

* Removing BOOST_TEST_MAIN

* Work in progress
This commit is contained in:
Michael Tryby
2019-04-11 18:04:20 -04:00
committed by GitHub
parent 8b4727eac5
commit 9c4665a661
10 changed files with 59 additions and 29 deletions

View File

@@ -1794,6 +1794,7 @@ int DLLEXPORT EN_addnode(EN_Project p, char *id, int nodeType)
{
nIdx = net->Nnodes + 1;
node = &net->Node[nIdx];
node->D = NULL;
net->Ntanks++;
// resize tanks array
@@ -1820,6 +1821,7 @@ int DLLEXPORT EN_addnode(EN_Project p, char *id, int nodeType)
tank->V1max = 10000;
}
net->Nnodes++;
p->parser.MaxNodes = net->Nnodes;
strncpy(node->ID, id, MAXID);
// set default values for new node

View File

@@ -401,7 +401,7 @@ void freedata(Project *pr)
// Free memory for node data
if (pr->network.Node != NULL)
{
for (j = 0; j <= pr->parser.MaxNodes; j++)
for (j = 1; j <= pr->parser.MaxNodes; j++)
{
// Free memory used for demand category list
demand = pr->network.Node[j].D;