Browse Source

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

by adding user defined delete function for hash table entries
pre-master-46
h_vogt 13 years ago
committed by rlar
parent
commit
94595c06df
  1. 1
      src/frontend/numparam/numparam.h
  2. 2
      src/frontend/numparam/spicenum.c
  3. 15
      src/frontend/numparam/xpressn.c

1
src/frontend/numparam/numparam.h

@ -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 *);

2
src/frontend/numparam/spicenum.c

@ -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;
}

15
src/frontend/numparam/xpressn.c

@ -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…
Cancel
Save