From f53384da70142f97f3d2e352a855bebebf37f386 Mon Sep 17 00:00:00 2001 From: rlar Date: Sun, 14 Jan 2018 11:08:32 +0100 Subject: [PATCH] devices/*, USE_OMP, cleanup 'InstanceArray' usage store 'InstanceArray' in the very first module only, NULL it in any other. FREE() it in every module to treat them all the same in XXXdestroy() --- src/spicelib/devices/bsim3/b3dest.c | 9 ++++----- src/spicelib/devices/bsim3/b3set.c | 8 +++++--- src/spicelib/devices/bsim3v32/b3v32dest.c | 10 +++++----- src/spicelib/devices/bsim3v32/b3v32set.c | 8 +++++--- src/spicelib/devices/bsim4/b4dest.c | 10 +++++----- src/spicelib/devices/bsim4/b4set.c | 8 +++++--- src/spicelib/devices/bsim4v5/b4v5dest.c | 10 +++++----- src/spicelib/devices/bsim4v5/b4v5set.c | 8 +++++--- src/spicelib/devices/bsim4v6/b4v6dest.c | 10 +++++----- src/spicelib/devices/bsim4v6/b4v6set.c | 8 +++++--- src/spicelib/devices/bsim4v7/b4v7dest.c | 10 +++++----- src/spicelib/devices/bsim4v7/b4v7set.c | 8 +++++--- src/spicelib/devices/bsimsoi/b4soidest.c | 10 +++++----- src/spicelib/devices/bsimsoi/b4soiset.c | 8 +++++--- src/spicelib/devices/hisim2/hsm2dest.c | 10 +++++----- src/spicelib/devices/hisim2/hsm2set.c | 8 +++++--- 16 files changed, 79 insertions(+), 64 deletions(-) diff --git a/src/spicelib/devices/bsim3/b3dest.c b/src/spicelib/devices/bsim3/b3dest.c index 27af1ba3b..2c0b83256 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 = mod->BSIM3nextModel; BSIM3instance *inst = mod->BSIM3instances; @@ -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); FREE(mod); diff --git a/src/spicelib/devices/bsim3/b3set.c b/src/spicelib/devices/bsim3/b3set.c index da14dd8dc..d4be61cbc 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 = model->BSIM3nextModel ) { @@ -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 b20736ffc..e71fe15a4 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 = mod->BSIM3v32nextModel; BSIM3v32instance *inst = mod->BSIM3v32instances; @@ -40,6 +35,11 @@ BSIM3v32destroy (GENmodel **inModel) FREE(inst); inst = next_inst; } + +#ifdef USE_OMP + FREE(mod->BSIM3v32InstanceArray); +#endif + FREE(mod->BSIM3v32version); FREE(mod); mod = next_mod; diff --git a/src/spicelib/devices/bsim3v32/b3v32set.c b/src/spicelib/devices/bsim3v32/b3v32set.c index 6025934ac..930add449 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 = model->BSIM3v32nextModel) { @@ -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 66379be0d..c6f1c46ab 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 = mod->BSIM4nextModel; BSIM4instance *inst = mod->BSIM4instances; @@ -89,6 +84,11 @@ BSIM4destroy(GENmodel **inModel) FREE(inst); inst = next_inst; } + +#ifdef USE_OMP + FREE(mod->BSIM4InstanceArray); +#endif + FREE(mod->BSIM4version); FREE(mod); mod = next_mod; diff --git a/src/spicelib/devices/bsim4/b4set.c b/src/spicelib/devices/bsim4/b4set.c index 7139ef8fc..94c70f2a2 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 = model->BSIM4nextModel ) { @@ -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 876062d46..ff4071263 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 = mod->BSIM4v5nextModel; BSIM4v5instance *inst = mod->BSIM4v5instances; @@ -39,6 +34,11 @@ BSIM4v5destroy(GENmodel **inModel) FREE(inst); inst = next_inst; } + +#ifdef USE_OMP + FREE(mod->BSIM4v5InstanceArray); +#endif + FREE(mod->BSIM4v5version); FREE(mod); mod = next_mod; diff --git a/src/spicelib/devices/bsim4v5/b4v5set.c b/src/spicelib/devices/bsim4v5/b4v5set.c index 6da70c71f..92fafb38b 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 = model->BSIM4v5nextModel) { @@ -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 0d1c5e64a..3db294dd9 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 = mod->BSIM4v6nextModel; BSIM4v6instance *inst = mod->BSIM4v6instances; @@ -41,6 +36,11 @@ BSIM4v6destroy(GENmodel **inModel) FREE(inst); inst = next_inst; } + +#ifdef USE_OMP + FREE(mod->BSIM4v6InstanceArray); +#endif + FREE(mod->BSIM4v6version); FREE(mod); mod = next_mod; diff --git a/src/spicelib/devices/bsim4v6/b4v6set.c b/src/spicelib/devices/bsim4v6/b4v6set.c index 3d71a4c8a..6971745e4 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 = model->BSIM4v6nextModel ) { @@ -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 206708b27..3a19dcee0 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 = mod->BSIM4v7nextModel; BSIM4v7instance *inst = mod->BSIM4v7instances; @@ -41,6 +36,11 @@ BSIM4v7destroy(GENmodel **inModel) FREE(inst); inst = next_inst; } + +#ifdef USE_OMP + FREE(mod->BSIM4v7InstanceArray); +#endif + /* mod->BSIM4v7modName to be freed in INPtabEnd() */ FREE(mod->BSIM4v7version); FREE(mod); diff --git a/src/spicelib/devices/bsim4v7/b4v7set.c b/src/spicelib/devices/bsim4v7/b4v7set.c index 107256bbf..ade75ad86 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 = model->BSIM4v7nextModel ) { @@ -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 0705e6df0..55cde8318 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 = mod->B4SOInextModel; B4SOIinstance *inst = mod->B4SOIinstances; @@ -37,6 +32,11 @@ B4SOIdestroy(GENmodel **inModel) FREE(inst); inst = next_inst; } + +#ifdef USE_OMP + FREE(mod->B4SOIInstanceArray); +#endif + FREE(mod); mod = next_mod; } diff --git a/src/spicelib/devices/bsimsoi/b4soiset.c b/src/spicelib/devices/bsimsoi/b4soiset.c index 78c36a02c..daf6ad576 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 = model->B4SOInextModel ) { @@ -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 32fbb857f..99c1d57cb 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 = mod->HSM2nextModel; HSM2instance *inst = mod->HSM2instances; @@ -77,6 +72,11 @@ HSM2destroy(GENmodel **inModel) FREE(inst); inst = next_inst; } + +#ifdef USE_OMP + FREE(mod->HSM2InstanceArray); +#endif + FREE(mod); mod = next_mod; } diff --git a/src/spicelib/devices/hisim2/hsm2set.c b/src/spicelib/devices/hisim2/hsm2set.c index d9f346241..7b031aba7 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 = model->HSM2nextModel ) { @@ -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