diff --git a/ChangeLog b/ChangeLog index deb8ba519..4d27edc47 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2011-12-30 Holger Vogt + * b4v5dest.c, b4dest.c : memory leaks reduced + 2011-12-30 Robert Larice * inpcom.c : cleanup, drop `s_lower' diff --git a/src/spicelib/devices/bsim4/b4dest.c b/src/spicelib/devices/bsim4/b4dest.c index c44713f73..255063869 100644 --- a/src/spicelib/devices/bsim4/b4dest.c +++ b/src/spicelib/devices/bsim4/b4dest.c @@ -16,25 +16,43 @@ void BSIM4destroy( -GENmodel **inModel) + GENmodel **inModel) { -BSIM4model **model = (BSIM4model**)inModel; -BSIM4instance *here; -BSIM4instance *prev = NULL; -BSIM4model *mod = *model; -BSIM4model *oldmod = NULL; + BSIM4model **model = (BSIM4model**)inModel; + BSIM4instance *here; + BSIM4instance *prev = NULL; + BSIM4model *mod = *model; + BSIM4model *oldmod = NULL; - for (; mod ; mod = mod->BSIM4nextModel) - { if(oldmod) FREE(oldmod); - oldmod = mod; - prev = (BSIM4instance *)NULL; - for (here = mod->BSIM4instances; here; here = here->BSIM4nextInstance) - { if(prev) FREE(prev); - prev = here; - } - if(prev) FREE(prev); + for (; mod ; mod = mod->BSIM4nextModel) { + /** 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; + prev = (BSIM4instance *)NULL; + for (here = mod->BSIM4instances; here; here = here->BSIM4nextInstance) { + if(prev) FREE(prev); + prev = here; + } + if(prev) FREE(prev); + } + if(oldmod) { +#ifdef USE_OMP4 + /* free just once for all models */ + FREE(oldmod->BSIM4InstanceArray); +#endif + FREE(oldmod); } - if(oldmod) FREE(oldmod); *model = NULL; return; } diff --git a/src/spicelib/devices/bsim4v5/b4v5dest.c b/src/spicelib/devices/bsim4v5/b4v5dest.c index fbaabe7c7..d62680e41 100644 --- a/src/spicelib/devices/bsim4v5/b4v5dest.c +++ b/src/spicelib/devices/bsim4v5/b4v5dest.c @@ -14,23 +14,35 @@ void BSIM4v5destroy( -GENmodel **inModel) + GENmodel **inModel) { -BSIM4v5model **model = (BSIM4v5model**)inModel; -BSIM4v5instance *here; -BSIM4v5instance *prev = NULL; -BSIM4v5model *mod = *model; -BSIM4v5model *oldmod = NULL; + BSIM4v5model **model = (BSIM4v5model**)inModel; + BSIM4v5instance *here; + BSIM4v5instance *prev = NULL; + BSIM4v5model *mod = *model; + BSIM4v5model *oldmod = NULL; - for (; mod ; mod = mod->BSIM4v5nextModel) - { if(oldmod) FREE(oldmod); - oldmod = mod; - prev = NULL; - for (here = mod->BSIM4v5instances; here; here = here->BSIM4v5nextInstance) - { if(prev) FREE(prev); - prev = here; - } - if(prev) FREE(prev); + for (; mod ; mod = mod->BSIM4v5nextModel) { + /** 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; + prev = NULL; + for (here = mod->BSIM4v5instances; here; here = here->BSIM4v5nextInstance) { + if(prev) FREE(prev); + prev = here; + } + if(prev) FREE(prev); } if(oldmod) FREE(oldmod); *model = NULL;