diff --git a/src/spicelib/devices/bsim3/b3dest.c b/src/spicelib/devices/bsim3/b3dest.c index f9ac980ca..b46890beb 100644 --- a/src/spicelib/devices/bsim3/b3dest.c +++ b/src/spicelib/devices/bsim3/b3dest.c @@ -18,11 +18,6 @@ BSIM3destroy(GENmodel **inModel) { BSIM3model *mod = *(BSIM3model**) inModel; - #ifdef USE_OMP - /* free just once for all models */ - FREE(mod->BSIM3InstanceArray); - #endif - while (mod) { BSIM3model *next_mod = BSIM3nextModel(mod); BSIM3instance *inst = BSIM3instances(mod); @@ -42,6 +37,10 @@ BSIM3destroy(GENmodel **inModel) inst = next_inst; } +#ifdef USE_OMP + FREE(mod->BSIM3InstanceArray); +#endif + /* mod->BSIM3modName to be freed in INPtabEnd() */ FREE(mod->BSIM3version); GENmodelFree(GENmodelOf(mod)); diff --git a/src/spicelib/devices/bsim3/b3set.c b/src/spicelib/devices/bsim3/b3set.c index dfec9894a..3eeac72e5 100644 --- a/src/spicelib/devices/bsim3/b3set.c +++ b/src/spicelib/devices/bsim3/b3set.c @@ -1137,9 +1137,14 @@ do { if((here->ptr = SMPmakeElt(matrix, here->first, here->second)) == NULL){\ { InstCount++; } + model->BSIM3InstCount = 0; + model->BSIM3InstanceArray = NULL; } InstArray = TMALLOC(BSIM3instance*, InstCount); model = (BSIM3model*)inModel; + /* store this in the first model only */ + model->BSIM3InstCount = InstCount; + model->BSIM3InstanceArray = InstArray; idx = 0; for( ; model != NULL; model = BSIM3nextModel(model) ) { @@ -1150,9 +1155,6 @@ do { if((here->ptr = SMPmakeElt(matrix, here->first, here->second)) == NULL){\ InstArray[idx] = here; idx++; } - /* set the array pointer and instance count into each model */ - model->BSIM3InstCount = InstCount; - model->BSIM3InstanceArray = InstArray; } #endif diff --git a/src/spicelib/devices/bsim3v32/b3v32dest.c b/src/spicelib/devices/bsim3v32/b3v32dest.c index cca76df53..139f6ac5c 100644 --- a/src/spicelib/devices/bsim3v32/b3v32dest.c +++ b/src/spicelib/devices/bsim3v32/b3v32dest.c @@ -19,11 +19,6 @@ BSIM3v32destroy (GENmodel **inModel) { BSIM3v32model *mod = *(BSIM3v32model**) inModel; -#ifdef USE_OMP - /* free just once for all models */ - FREE(mod->BSIM3v32InstanceArray); -#endif - while (mod) { BSIM3v32model *next_mod = BSIM3v32nextModel(mod); BSIM3v32instance *inst = BSIM3v32instances(mod); @@ -40,6 +35,11 @@ BSIM3v32destroy (GENmodel **inModel) GENinstanceFree(GENinstanceOf(inst)); inst = next_inst; } + +#ifdef USE_OMP + FREE(mod->BSIM3v32InstanceArray); +#endif + FREE(mod->BSIM3v32version); GENmodelFree(GENmodelOf(mod)); mod = next_mod; diff --git a/src/spicelib/devices/bsim3v32/b3v32set.c b/src/spicelib/devices/bsim3v32/b3v32set.c index 456a98095..5ae66ac08 100644 --- a/src/spicelib/devices/bsim3v32/b3v32set.c +++ b/src/spicelib/devices/bsim3v32/b3v32set.c @@ -1149,9 +1149,14 @@ do { if((here->ptr = SMPmakeElt(matrix, here->first, here->second)) == NULL){\ { InstCount++; } + model->BSIM3v32InstCount = 0; + model->BSIM3v32InstanceArray = NULL; } InstArray = TMALLOC(BSIM3v32instance*, InstCount); model = (BSIM3v32model*)inModel; + /* store this in the first model only */ + model->BSIM3v32InstCount = InstCount; + model->BSIM3v32InstanceArray = InstArray; idx = 0; for (; model != NULL; model = BSIM3v32nextModel(model)) { @@ -1162,9 +1167,6 @@ do { if((here->ptr = SMPmakeElt(matrix, here->first, here->second)) == NULL){\ InstArray[idx] = here; idx++; } - /* set the array pointer and instance count into each model */ - model->BSIM3v32InstCount = InstCount; - model->BSIM3v32InstanceArray = InstArray; } #endif diff --git a/src/spicelib/devices/bsim4/b4dest.c b/src/spicelib/devices/bsim4/b4dest.c index 36d133ed3..a2c5d09e8 100644 --- a/src/spicelib/devices/bsim4/b4dest.c +++ b/src/spicelib/devices/bsim4/b4dest.c @@ -68,11 +68,6 @@ BSIM4destroy(GENmodel **inModel) { BSIM4model *mod = *(BSIM4model**) inModel; -#ifdef USE_OMP - /* free just once for all models */ - FREE(mod->BSIM4InstanceArray); -#endif - while (mod) { BSIM4model *next_mod = BSIM4nextModel(mod); BSIM4instance *inst = BSIM4instances(mod); @@ -89,6 +84,11 @@ BSIM4destroy(GENmodel **inModel) GENinstanceFree(GENinstanceOf(inst)); inst = next_inst; } + +#ifdef USE_OMP + FREE(mod->BSIM4InstanceArray); +#endif + FREE(mod->BSIM4version); GENmodelFree(GENmodelOf(mod)); mod = next_mod; diff --git a/src/spicelib/devices/bsim4/b4set.c b/src/spicelib/devices/bsim4/b4set.c index 7064de907..4516115f6 100644 --- a/src/spicelib/devices/bsim4/b4set.c +++ b/src/spicelib/devices/bsim4/b4set.c @@ -2728,9 +2728,14 @@ do { if((here->ptr = SMPmakeElt(matrix,here->first,here->second))==(double *)NUL { InstCount++; } + model->BSIM4InstCount = 0; + model->BSIM4InstanceArray = NULL; } InstArray = TMALLOC(BSIM4instance*, InstCount); model = (BSIM4model*)inModel; + /* store this in the first model only */ + model->BSIM4InstCount = InstCount; + model->BSIM4InstanceArray = InstArray; idx = 0; for( ; model != NULL; model = BSIM4nextModel(model) ) { @@ -2741,9 +2746,6 @@ do { if((here->ptr = SMPmakeElt(matrix,here->first,here->second))==(double *)NUL InstArray[idx] = here; idx++; } - /* set the array pointer and instance count into each model */ - model->BSIM4InstCount = InstCount; - model->BSIM4InstanceArray = InstArray; } #endif diff --git a/src/spicelib/devices/bsim4v5/b4v5dest.c b/src/spicelib/devices/bsim4v5/b4v5dest.c index 0a0806eff..0e5b24dfb 100644 --- a/src/spicelib/devices/bsim4v5/b4v5dest.c +++ b/src/spicelib/devices/bsim4v5/b4v5dest.c @@ -18,11 +18,6 @@ BSIM4v5destroy(GENmodel **inModel) { BSIM4v5model *mod = *(BSIM4v5model**) inModel; -#ifdef USE_OMP - /* free just once for all models */ - FREE(mod->BSIM4v5InstanceArray); -#endif - while (mod) { BSIM4v5model *next_mod = BSIM4v5nextModel(mod); BSIM4v5instance *inst = BSIM4v5instances(mod); @@ -39,6 +34,11 @@ BSIM4v5destroy(GENmodel **inModel) GENinstanceFree(GENinstanceOf(inst)); inst = next_inst; } + +#ifdef USE_OMP + FREE(mod->BSIM4v5InstanceArray); +#endif + FREE(mod->BSIM4v5version); GENmodelFree(GENmodelOf(mod)); mod = next_mod; diff --git a/src/spicelib/devices/bsim4v5/b4v5set.c b/src/spicelib/devices/bsim4v5/b4v5set.c index 71dd06a16..4c3abed49 100644 --- a/src/spicelib/devices/bsim4v5/b4v5set.c +++ b/src/spicelib/devices/bsim4v5/b4v5set.c @@ -2106,9 +2106,14 @@ do { if((here->ptr = SMPmakeElt(matrix, here->first, here->second)) == NULL){\ { InstCount++; } + model->BSIM4v5InstCount = 0; + model->BSIM4v5InstanceArray = NULL; } InstArray = TMALLOC(BSIM4v5instance*, InstCount); model = (BSIM4v5model*)inModel; + /* store this in the first model only */ + model->BSIM4v5InstCount = InstCount; + model->BSIM4v5InstanceArray = InstArray; idx = 0; for (; model != NULL; model = BSIM4v5nextModel(model)) { @@ -2119,9 +2124,6 @@ do { if((here->ptr = SMPmakeElt(matrix, here->first, here->second)) == NULL){\ InstArray[idx] = here; idx++; } - /* set the array pointer and instance count into each model */ - model->BSIM4v5InstCount = InstCount; - model->BSIM4v5InstanceArray = InstArray; } #endif diff --git a/src/spicelib/devices/bsim4v6/b4v6dest.c b/src/spicelib/devices/bsim4v6/b4v6dest.c index 914f3d7f0..3d53486a3 100644 --- a/src/spicelib/devices/bsim4v6/b4v6dest.c +++ b/src/spicelib/devices/bsim4v6/b4v6dest.c @@ -20,11 +20,6 @@ BSIM4v6destroy(GENmodel **inModel) { BSIM4v6model *mod = *(BSIM4v6model**) inModel; -#ifdef USE_OMP - /* free just once for all models */ - FREE(mod->BSIM4v6InstanceArray); -#endif - while (mod) { BSIM4v6model *next_mod = BSIM4v6nextModel(mod); BSIM4v6instance *inst = BSIM4v6instances(mod); @@ -41,6 +36,11 @@ BSIM4v6destroy(GENmodel **inModel) GENinstanceFree(GENinstanceOf(inst)); inst = next_inst; } + +#ifdef USE_OMP + FREE(mod->BSIM4v6InstanceArray); +#endif + FREE(mod->BSIM4v6version); GENmodelFree(GENmodelOf(mod)); mod = next_mod; diff --git a/src/spicelib/devices/bsim4v6/b4v6set.c b/src/spicelib/devices/bsim4v6/b4v6set.c index bc376318b..f5822c956 100644 --- a/src/spicelib/devices/bsim4v6/b4v6set.c +++ b/src/spicelib/devices/bsim4v6/b4v6set.c @@ -2441,9 +2441,14 @@ do { if((here->ptr = SMPmakeElt(matrix, here->first, here->second)) == NULL){\ { InstCount++; } + model->BSIM4v6InstCount = 0; + model->BSIM4v6InstanceArray = NULL; } InstArray = TMALLOC(BSIM4v6instance*, InstCount); model = (BSIM4v6model*)inModel; + /* store this in the first model only */ + model->BSIM4v6InstCount = InstCount; + model->BSIM4v6InstanceArray = InstArray; idx = 0; for( ; model != NULL; model = BSIM4v6nextModel(model) ) { @@ -2454,9 +2459,6 @@ do { if((here->ptr = SMPmakeElt(matrix, here->first, here->second)) == NULL){\ InstArray[idx] = here; idx++; } - /* set the array pointer and instance count into each model */ - model->BSIM4v6InstCount = InstCount; - model->BSIM4v6InstanceArray = InstArray; } #endif diff --git a/src/spicelib/devices/bsim4v7/b4v7dest.c b/src/spicelib/devices/bsim4v7/b4v7dest.c index be887ed5d..4cfdab872 100644 --- a/src/spicelib/devices/bsim4v7/b4v7dest.c +++ b/src/spicelib/devices/bsim4v7/b4v7dest.c @@ -20,11 +20,6 @@ BSIM4v7destroy(GENmodel **inModel) { BSIM4v7model *mod = *(BSIM4v7model**) inModel; -#ifdef USE_OMP - /* free just once for all models */ - FREE(mod->BSIM4v7InstanceArray); -#endif - while (mod) { BSIM4v7model *next_mod = BSIM4v7nextModel(mod); BSIM4v7instance *inst = BSIM4v7instances(mod); @@ -41,6 +36,11 @@ BSIM4v7destroy(GENmodel **inModel) GENinstanceFree(GENinstanceOf(inst)); inst = next_inst; } + +#ifdef USE_OMP + FREE(mod->BSIM4v7InstanceArray); +#endif + /* mod->BSIM4v7modName to be freed in INPtabEnd() */ FREE(mod->BSIM4v7version); GENmodelFree(GENmodelOf(mod)); diff --git a/src/spicelib/devices/bsim4v7/b4v7set.c b/src/spicelib/devices/bsim4v7/b4v7set.c index 0c8275447..9eb29b43a 100644 --- a/src/spicelib/devices/bsim4v7/b4v7set.c +++ b/src/spicelib/devices/bsim4v7/b4v7set.c @@ -2596,9 +2596,14 @@ do { if((here->ptr = SMPmakeElt(matrix,here->first,here->second))==(double *)NUL { InstCount++; } + model->BSIM4v7InstCount = 0; + model->BSIM4v7InstanceArray = NULL; } InstArray = TMALLOC(BSIM4v7instance*, InstCount); model = (BSIM4v7model*)inModel; + /* store this in the first model only */ + model->BSIM4v7InstCount = InstCount; + model->BSIM4v7InstanceArray = InstArray; idx = 0; for( ; model != NULL; model = BSIM4v7nextModel(model) ) { @@ -2609,9 +2614,6 @@ do { if((here->ptr = SMPmakeElt(matrix,here->first,here->second))==(double *)NUL InstArray[idx] = here; idx++; } - /* set the array pointer and instance count into each model */ - model->BSIM4v7InstCount = InstCount; - model->BSIM4v7InstanceArray = InstArray; } #endif diff --git a/src/spicelib/devices/bsimsoi/b4soidest.c b/src/spicelib/devices/bsimsoi/b4soidest.c index c074941c7..0c18d7fe1 100644 --- a/src/spicelib/devices/bsimsoi/b4soidest.c +++ b/src/spicelib/devices/bsimsoi/b4soidest.c @@ -24,11 +24,6 @@ B4SOIdestroy(GENmodel **inModel) { B4SOImodel *mod = *(B4SOImodel**) inModel; -#ifdef USE_OMP - /* free just once for all models */ - FREE(mod->B4SOIInstanceArray); -#endif - while (mod) { B4SOImodel *next_mod = B4SOInextModel(mod); B4SOIinstance *inst = B4SOIinstances(mod); @@ -37,6 +32,11 @@ B4SOIdestroy(GENmodel **inModel) GENinstanceFree(GENinstanceOf(inst)); inst = next_inst; } + +#ifdef USE_OMP + FREE(mod->B4SOIInstanceArray); +#endif + GENmodelFree(GENmodelOf(mod)); mod = next_mod; } diff --git a/src/spicelib/devices/bsimsoi/b4soiset.c b/src/spicelib/devices/bsimsoi/b4soiset.c index 7ef46e136..701cb2d25 100644 --- a/src/spicelib/devices/bsimsoi/b4soiset.c +++ b/src/spicelib/devices/bsimsoi/b4soiset.c @@ -2733,9 +2733,14 @@ do { if((here->ptr = SMPmakeElt(matrix,here->first,here->second))==(double *)NUL { InstCount++; } + model->B4SOIInstCount = 0; + model->B4SOIInstanceArray = NULL; } InstArray = TMALLOC(B4SOIinstance*, InstCount); model = (B4SOImodel*)inModel; + /* store this in the first model only */ + model->B4SOIInstCount = InstCount; + model->B4SOIInstanceArray = InstArray; idx = 0; for( ; model != NULL; model = B4SOInextModel(model) ) { @@ -2746,9 +2751,6 @@ do { if((here->ptr = SMPmakeElt(matrix,here->first,here->second))==(double *)NUL InstArray[idx] = here; idx++; } - /* set the array pointer and instance count into each model */ - model->B4SOIInstCount = InstCount; - model->B4SOIInstanceArray = InstArray; } #endif diff --git a/src/spicelib/devices/hisim2/hsm2dest.c b/src/spicelib/devices/hisim2/hsm2dest.c index 03ec5fc57..7fa7ecf0f 100644 --- a/src/spicelib/devices/hisim2/hsm2dest.c +++ b/src/spicelib/devices/hisim2/hsm2dest.c @@ -64,11 +64,6 @@ HSM2destroy(GENmodel **inModel) { HSM2model *mod = *(HSM2model**) inModel; -#ifdef USE_OMP - /* free just once for all models */ - FREE(mod->HSM2InstanceArray); -#endif - while (mod) { HSM2model *next_mod = HSM2nextModel(mod); HSM2instance *inst = HSM2instances(mod); @@ -77,6 +72,11 @@ HSM2destroy(GENmodel **inModel) GENinstanceFree(GENinstanceOf(inst)); inst = next_inst; } + +#ifdef USE_OMP + FREE(mod->HSM2InstanceArray); +#endif + GENmodelFree(GENmodelOf(mod)); mod = next_mod; } diff --git a/src/spicelib/devices/hisim2/hsm2set.c b/src/spicelib/devices/hisim2/hsm2set.c index e88c5fdd4..360c1140e 100644 --- a/src/spicelib/devices/hisim2/hsm2set.c +++ b/src/spicelib/devices/hisim2/hsm2set.c @@ -1275,9 +1275,14 @@ do { if((here->ptr = SMPmakeElt(matrix,here->first,here->second))==(double *)NUL { InstCount++; } + model->HSM2InstCount = 0; + model->HSM2InstanceArray = NULL; } InstArray = TMALLOC(HSM2instance*, InstCount); model = (HSM2model*)inModel; + /* store this in the first model only */ + model->HSM2InstCount = InstCount; + model->HSM2InstanceArray = InstArray; idx = 0; for ( ; model != NULL; model = HSM2nextModel(model) ) { @@ -1288,9 +1293,6 @@ do { if((here->ptr = SMPmakeElt(matrix,here->first,here->second))==(double *)NUL InstArray[idx] = here; idx++; } - /* set the array pointer and instance count into each model */ - model->HSM2InstCount = InstCount; - model->HSM2InstanceArray = InstArray; } #endif