spicenum.c, xpressn.c: plug setup memory leak

by adding user defined delete function for hash table entries
This commit is contained in:
h_vogt 2013-08-21 20:52:05 +02:00 committed by rlar
parent fceefb700c
commit 94595c06df
3 changed files with 17 additions and 1 deletions

View File

@ -77,3 +77,4 @@ void nupa_subcktexit(tdico *dico);
tdico *nupa_fetchinstance(void);
char getidtype(tdico *d, char *s);
entry *attrib(tdico *d, NGHASHPTR htable, char *t, char op);
void del_attrib(entry *);

View File

@ -489,7 +489,7 @@ nupa_del_dicoS(void)
dispose(dicoS->dyncategory);
dispose(dicoS->inst_name);
dispose(dicoS->local_symbols);
nghash_free(dicoS->global_symbols, NULL, NULL);
nghash_free(dicoS->global_symbols, del_attrib, NULL);
dispose(dicoS);
dicoS = NULL;
}

View File

@ -439,6 +439,21 @@ attrib(tdico *dico_p, NGHASHPTR htable_p, char *t, char op)
}
/* user defined delete function:
* free the dictionary entries malloc'ed above
* will be called by nghash_free() in nupa_del_dicoS()
*/
void
del_attrib(entry *entry_p)
{
if(entry_p) {
tfree(entry_p->symbol);
tfree(entry_p);
}
}
static bool
define(tdico *dico,
char *t, /* identifier to define */