diff --git a/ChangeLog b/ChangeLog index 4d27edc47..f6aa2b114 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ 2011-12-30 Holger Vogt - * b4v5dest.c, b4dest.c : memory leaks reduced - + * b4v5dest.c, b4dest.c, b3dest, b3v32.dest : memory leaks reduced + * b3v32... : struct bsim3SizeDependParam --> struct bsim3v32SizeDependParam + 2011-12-30 Robert Larice * inpcom.c : cleanup, drop `s_lower' diff --git a/src/spicelib/devices/bsim3/b3dest.c b/src/spicelib/devices/bsim3/b3dest.c index 1868a41dc..0141a5168 100644 --- a/src/spicelib/devices/bsim3/b3dest.c +++ b/src/spicelib/devices/bsim3/b3dest.c @@ -3,7 +3,7 @@ /********** * Copyright 2004 Regents of the University of California. All rights reserved. * File: b3dest.c of BSIM3v3.3.0 - * Author: 1995 Min-Chie Jeng and Mansun Chan. + * Author: 1995 Min-Chie Jeng and Mansun Chan. * Author: 1997-1999 Weidong Liu. * Author: 2001 Xuemei Xi **********/ @@ -14,25 +14,43 @@ void BSIM3destroy( -GENmodel **inModel) + GENmodel **inModel) { -BSIM3model **model = (BSIM3model**)inModel; -BSIM3instance *here; -BSIM3instance *prev = NULL; -BSIM3model *mod = *model; -BSIM3model *oldmod = NULL; + BSIM3model **model = (BSIM3model**)inModel; + BSIM3instance *here; + BSIM3instance *prev = NULL; + BSIM3model *mod = *model; + BSIM3model *oldmod = NULL; - for (; mod ; mod = mod->BSIM3nextModel) - { if(oldmod) FREE(oldmod); - oldmod = mod; - prev = NULL; - for (here = mod->BSIM3instances; here; here = here->BSIM3nextInstance) - { if(prev) FREE(prev); - prev = here; - } - if(prev) FREE(prev); + for (; mod ; mod = mod->BSIM3nextModel) { + /** added to get rid of link list pSizeDependParamKnot **/ + struct bsim3SizeDependParam *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->BSIM3instances; here; here = here->BSIM3nextInstance) { + if(prev) FREE(prev); + prev = here; + } + if(prev) FREE(prev); + } + if(oldmod) { +#ifdef USE_OMP3 + /* free just once for all models */ + FREE(oldmod->BSIM3InstanceArray); +#endif + FREE(oldmod); } - if(oldmod) FREE(oldmod); *model = NULL; return; } diff --git a/src/spicelib/devices/bsim3v32/b3v32check.c b/src/spicelib/devices/bsim3v32/b3v32check.c index 25c522b9f..7f85e07a5 100644 --- a/src/spicelib/devices/bsim3v32/b3v32check.c +++ b/src/spicelib/devices/bsim3v32/b3v32check.c @@ -22,7 +22,7 @@ int BSIM3v32checkModel (BSIM3v32model *model, BSIM3v32instance *here, CKTcircuit *ckt) { -struct bsim3SizeDependParam *pParam; +struct bsim3v32SizeDependParam *pParam; int Fatal_Flag = 0; FILE *fplog; diff --git a/src/spicelib/devices/bsim3v32/b3v32dest.c b/src/spicelib/devices/bsim3v32/b3v32dest.c index 3260c32fb..b3e05f67b 100644 --- a/src/spicelib/devices/bsim3v32/b3v32dest.c +++ b/src/spicelib/devices/bsim3v32/b3v32dest.c @@ -3,7 +3,7 @@ /********** * Copyright 2001 Regents of the University of California. All rights reserved. * File: b3dest.c of BSIM3v3.2.4 - * Author: 1995 Min-Chie Jeng and Mansun Chan. + * Author: 1995 Min-Chie Jeng and Mansun Chan. * Author: 1997-1999 Weidong Liu. * Author: 2001 Xuemei Xi * Modified by Paolo Nenzi 2002 @@ -16,21 +16,33 @@ void BSIM3v32destroy (GENmodel **inModel) { -BSIM3v32model **model = (BSIM3v32model**)inModel; -BSIM3v32instance *here; -BSIM3v32instance *prev = NULL; -BSIM3v32model *mod = *model; -BSIM3v32model *oldmod = NULL; + BSIM3v32model **model = (BSIM3v32model**)inModel; + BSIM3v32instance *here; + BSIM3v32instance *prev = NULL; + BSIM3v32model *mod = *model; + BSIM3v32model *oldmod = NULL; - for (; mod ; mod = mod->BSIM3v32nextModel) - { if(oldmod) FREE(oldmod); - oldmod = mod; - prev = NULL; - for (here = mod->BSIM3v32instances; here; here = here->BSIM3v32nextInstance) - { if(prev) FREE(prev); - prev = here; - } - if(prev) FREE(prev); + for (; mod ; mod = mod->BSIM3v32nextModel) { + /** added to get rid of link list pSizeDependParamKnot **/ + struct bsim3v32SizeDependParam *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->BSIM3v32instances; here; here = here->BSIM3v32nextInstance) { + if(prev) FREE(prev); + prev = here; + } + if(prev) FREE(prev); } if(oldmod) FREE(oldmod); *model = NULL; diff --git a/src/spicelib/devices/bsim3v32/b3v32ld.c b/src/spicelib/devices/bsim3v32/b3v32ld.c index 1635d9777..c21c4d626 100644 --- a/src/spicelib/devices/bsim3v32/b3v32ld.c +++ b/src/spicelib/devices/bsim3v32/b3v32ld.c @@ -133,7 +133,7 @@ double dQsub0_dVd, dQsub0_dVb; double m; -struct bsim3SizeDependParam *pParam; +struct bsim3v32SizeDependParam *pParam; int ByPass, Check, ChargeComputationNeeded, error; ScalingFactor = 1.0e-9; diff --git a/src/spicelib/devices/bsim3v32/b3v32noi.c b/src/spicelib/devices/bsim3v32/b3v32noi.c index 0eda31a40..5f56aedf6 100644 --- a/src/spicelib/devices/bsim3v32/b3v32noi.c +++ b/src/spicelib/devices/bsim3v32/b3v32noi.c @@ -65,7 +65,7 @@ static double StrongInversionNoiseEvalNew(double Vds, BSIM3v32model *model, BSIM3v32instance *here, double freq, double temp) { -struct bsim3SizeDependParam *pParam; +struct bsim3v32SizeDependParam *pParam; double cd, esat, DelClm, EffFreq, N0, Nl; double T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, Ssi; @@ -111,7 +111,7 @@ static double StrongInversionNoiseEvalOld(double vgs, double vds, BSIM3v32model *model, BSIM3v32instance *here, double freq, double temp) { - struct bsim3SizeDependParam *pParam; + struct bsim3v32SizeDependParam *pParam; double cd, esat, DelClm, EffFreq, N0, Nl, Vgst; double T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, Ssi; @@ -182,7 +182,7 @@ NOISEAN *job = (NOISEAN *) ckt->CKTcurJob; BSIM3v32model *model = (BSIM3v32model *)inModel; BSIM3v32instance *here; -struct bsim3SizeDependParam *pParam; +struct bsim3v32SizeDependParam *pParam; char name[N_MXVLNTH]; double tempOnoise; double tempInoise; diff --git a/src/spicelib/devices/bsim3v32/b3v32temp.c b/src/spicelib/devices/bsim3v32/b3v32temp.c index afc32da17..8a9ced017 100644 --- a/src/spicelib/devices/bsim3v32/b3v32temp.c +++ b/src/spicelib/devices/bsim3v32/b3v32temp.c @@ -33,7 +33,7 @@ BSIM3v32temp (GENmodel *inModel, CKTcircuit *ckt) { BSIM3v32model *model = (BSIM3v32model*) inModel; BSIM3v32instance *here; -struct bsim3SizeDependParam *pSizeDependParamKnot, *pLastKnot, *pParam=NULL; +struct bsim3v32SizeDependParam *pSizeDependParamKnot, *pLastKnot, *pParam=NULL; double tmp, tmp1, tmp2, tmp3, Eg, Eg0, ni, T0, T1, T2, T3, T4, T5, Ldrn, Wdrn; double delTemp, Temp, TRatio, Inv_L, Inv_W, Inv_LW, Vtm0, Tnom; double Nvtm, SourceSatCurrent, DrainSatCurrent; @@ -231,7 +231,7 @@ int Size_Not_Found; } if (Size_Not_Found) - { pParam = TMALLOC(struct bsim3SizeDependParam, 1); + { pParam = TMALLOC(struct bsim3v32SizeDependParam, 1); if (pLastKnot == NULL) model->pSizeDependParamKnot = pParam; else diff --git a/src/spicelib/devices/bsim3v32/bsim3v32def.h b/src/spicelib/devices/bsim3v32/bsim3v32def.h index 201d8dbdf..726fc0c13 100644 --- a/src/spicelib/devices/bsim3v32/bsim3v32def.h +++ b/src/spicelib/devices/bsim3v32/bsim3v32def.h @@ -117,7 +117,7 @@ typedef struct sBSIM3v32instance double BSIM3v32Abulk; double BSIM3v32AbovVgst2Vtm; - struct bsim3SizeDependParam *pParam; + struct bsim3v32SizeDependParam *pParam; unsigned BSIM3v32lGiven :1; unsigned BSIM3v32wGiven :1; @@ -213,7 +213,7 @@ typedef struct sBSIM3v32instance } BSIM3v32instance ; -struct bsim3SizeDependParam +struct bsim3v32SizeDependParam { double Width; double Length; @@ -347,7 +347,7 @@ struct bsim3SizeDependParam double BSIM3v32k1ox; double BSIM3v32k2ox; - struct bsim3SizeDependParam *pNext; + struct bsim3v32SizeDependParam *pNext; }; @@ -820,7 +820,7 @@ typedef struct sBSIM3v32model double BSIM3v32af; double BSIM3v32kf; - struct bsim3SizeDependParam *pSizeDependParamKnot; + struct bsim3v32SizeDependParam *pSizeDependParamKnot; /* Flags */ unsigned BSIM3v32mobModGiven :1;