diff --git a/examples/xspice/table/table-model-mos-3d-5.sp b/examples/xspice/table/table-model-mos-3d-5.sp index 378517512..73cf596cc 100644 --- a/examples/xspice/table/table-model-mos-3d-5.sp +++ b/examples/xspice/table/table-model-mos-3d-5.sp @@ -9,6 +9,8 @@ option trtol=1 tran 100p 20n *plot i(Vs) i(Vs2) plot v(in1) +tran 100p 20n +plot v(in1) rusage .endc * diff --git a/src/include/ngspice/mifcmdat.h b/src/include/ngspice/mifcmdat.h index 330831d6e..213713c6c 100644 --- a/src/include/ngspice/mifcmdat.h +++ b/src/include/ngspice/mifcmdat.h @@ -328,6 +328,7 @@ typedef struct Mif_Param_Data_s { Mif_Boolean_t is_null; /* True if no value given on .model card */ int size; /* Size of array (1 if scalar) */ Mif_Value_t *element; /* Value of parameter(s) */ + int eltype; /* type of the element */ } Mif_Param_Data_t; diff --git a/src/xspice/mif/mifmdelete.c b/src/xspice/mif/mifmdelete.c index e1472696b..b46274d02 100644 --- a/src/xspice/mif/mifmdelete.c +++ b/src/xspice/mif/mifmdelete.c @@ -64,12 +64,19 @@ int MIFmDelete(GENmodel *gen_model) { MIFmodel *model = (MIFmodel *) gen_model; - int i; + int i, j; /* Free the model params stuff allocated in MIFget_mod */ for (i = 0; i < model->num_param; i++) { - if (model->param[i]->element) + /* delete content of union 'element' if it contains a string */ + if (model->param[i]->element) { + if (model->param[i]->eltype == IF_STRING) + FREE(model->param[i]->element[0].svalue); + else if (model->param[i]->eltype == IF_STRINGVEC) + for (j = 0; j < model->param[i]->size; j++) + FREE(model->param[i]->element[j].svalue); FREE(model->param[i]->element); + } FREE(model->param[i]); } FREE(model->param); diff --git a/src/xspice/mif/mifmpara.c b/src/xspice/mif/mifmpara.c index 8f0753147..5fb0b8a2e 100644 --- a/src/xspice/mif/mifmpara.c +++ b/src/xspice/mif/mifmpara.c @@ -129,14 +129,17 @@ int MIFmParam( case IF_FLAG: model->param[param_index]->element[0].bvalue = value->iValue; + model->param[param_index]->eltype = IF_FLAG; break; case IF_INTEGER: model->param[param_index]->element[0].ivalue = value->iValue; + model->param[param_index]->eltype = IF_INTEGER; break; case IF_REAL: model->param[param_index]->element[0].rvalue = value->rValue; + model->param[param_index]->eltype = IF_REAL; break; case IF_STRING: @@ -144,6 +147,7 @@ int MIFmParam( model->param[param_index]->element[0].svalue = TMALLOC(char, 1 + strlen(value->sValue)); strcpy(model->param[param_index]->element[0].svalue, value->sValue); + model->param[param_index]->eltype = IF_STRING; break; case IF_COMPLEX: @@ -151,6 +155,7 @@ int MIFmParam( /* so copy the real and imaginary parts explicitly */ model->param[param_index]->element[0].cvalue.real = value->cValue.real; model->param[param_index]->element[0].cvalue.imag = value->cValue.imag; + model->param[param_index]->eltype = IF_COMPLEX; break; default: @@ -166,14 +171,17 @@ int MIFmParam( case IF_FLAGVEC: model->param[param_index]->element[i].bvalue = value->v.vec.iVec[i]; + model->param[param_index]->eltype = IF_FLAGVEC; break; case IF_INTVEC: model->param[param_index]->element[i].ivalue = value->v.vec.iVec[i]; + model->param[param_index]->eltype = IF_INTVEC; break; case IF_REALVEC: model->param[param_index]->element[i].rvalue = value->v.vec.rVec[i]; + model->param[param_index]->eltype = IF_REALVEC; break; case IF_STRINGVEC: @@ -181,6 +189,7 @@ int MIFmParam( model->param[param_index]->element[i].svalue = TMALLOC(char, 1 + strlen(value->v.vec.sVec[i])); strcpy(model->param[param_index]->element[i].svalue, value->v.vec.sVec[i]); + model->param[param_index]->eltype = IF_STRINGVEC; break; case IF_CPLXVEC: @@ -188,6 +197,7 @@ int MIFmParam( /* so copy the real and imaginary parts explicitly */ model->param[param_index]->element[i].cvalue.real = value->v.vec.cVec[i].real; model->param[param_index]->element[i].cvalue.imag = value->v.vec.cVec[i].imag; + model->param[param_index]->eltype = IF_CPLXVEC; break; default: