memory leaks reduced

This commit is contained in:
h_vogt 2011-12-30 18:54:44 +00:00
parent f1b516f1b1
commit 7a2b51b485
3 changed files with 64 additions and 31 deletions

View File

@ -1,3 +1,6 @@
2011-12-30 Holger Vogt
* b4v5dest.c, b4dest.c : memory leaks reduced
2011-12-30 Robert Larice 2011-12-30 Robert Larice
* inpcom.c : * inpcom.c :
cleanup, drop `s_lower' cleanup, drop `s_lower'

View File

@ -16,25 +16,43 @@
void void
BSIM4destroy( BSIM4destroy(
GENmodel **inModel) GENmodel **inModel)
{ {
BSIM4model **model = (BSIM4model**)inModel; BSIM4model **model = (BSIM4model**)inModel;
BSIM4instance *here; BSIM4instance *here;
BSIM4instance *prev = NULL; BSIM4instance *prev = NULL;
BSIM4model *mod = *model; BSIM4model *mod = *model;
BSIM4model *oldmod = NULL; BSIM4model *oldmod = NULL;
for (; mod ; mod = mod->BSIM4nextModel) for (; mod ; mod = mod->BSIM4nextModel) {
{ if(oldmod) FREE(oldmod); /** added to get rid of link list pSizeDependParamKnot **/
struct bsim4SizeDependParam *pParam, *pParamOld=NULL;
pParam = mod->pSizeDependParamKnot;
for (; pParam ; pParam = pParam->pNext) {
FREE(pParamOld);
pParamOld = pParam;
}
FREE(pParamOld);
pParam = NULL;
/** end of extra code **/
if(oldmod) FREE(oldmod);
oldmod = mod; oldmod = mod;
prev = (BSIM4instance *)NULL; prev = (BSIM4instance *)NULL;
for (here = mod->BSIM4instances; here; here = here->BSIM4nextInstance) for (here = mod->BSIM4instances; here; here = here->BSIM4nextInstance) {
{ if(prev) FREE(prev); if(prev) FREE(prev);
prev = here; prev = here;
} }
if(prev) FREE(prev); if(prev) FREE(prev);
} }
if(oldmod) FREE(oldmod); if(oldmod) {
#ifdef USE_OMP4
/* free just once for all models */
FREE(oldmod->BSIM4InstanceArray);
#endif
FREE(oldmod);
}
*model = NULL; *model = NULL;
return; return;
} }

View File

@ -14,20 +14,32 @@
void void
BSIM4v5destroy( BSIM4v5destroy(
GENmodel **inModel) GENmodel **inModel)
{ {
BSIM4v5model **model = (BSIM4v5model**)inModel; BSIM4v5model **model = (BSIM4v5model**)inModel;
BSIM4v5instance *here; BSIM4v5instance *here;
BSIM4v5instance *prev = NULL; BSIM4v5instance *prev = NULL;
BSIM4v5model *mod = *model; BSIM4v5model *mod = *model;
BSIM4v5model *oldmod = NULL; BSIM4v5model *oldmod = NULL;
for (; mod ; mod = mod->BSIM4v5nextModel) for (; mod ; mod = mod->BSIM4v5nextModel) {
{ if(oldmod) FREE(oldmod); /** added to get rid of link list pSizeDependParamKnot **/
struct bsim4v5SizeDependParam *pParam, *pParamOld=NULL;
pParam = mod->pSizeDependParamKnot;
for (; pParam ; pParam = pParam->pNext) {
FREE(pParamOld);
pParamOld = pParam;
}
FREE(pParamOld);
pParam = NULL;
/** end of extra code **/
if(oldmod) FREE(oldmod);
oldmod = mod; oldmod = mod;
prev = NULL; prev = NULL;
for (here = mod->BSIM4v5instances; here; here = here->BSIM4v5nextInstance) for (here = mod->BSIM4v5instances; here; here = here->BSIM4v5nextInstance) {
{ if(prev) FREE(prev); if(prev) FREE(prev);
prev = here; prev = here;
} }
if(prev) FREE(prev); if(prev) FREE(prev);