spicenum.c, xpressn.c: plug setup memory leak
by adding user defined delete function for hash table entries
This commit is contained in:
parent
fceefb700c
commit
94595c06df
|
|
@ -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 *);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
Loading…
Reference in New Issue