diff --git a/src/xspice/icm/table/table2D/cfunc.mod b/src/xspice/icm/table/table2D/cfunc.mod index 4a21b2a3f..fcfa55fec 100644 --- a/src/xspice/icm/table/table2D/cfunc.mod +++ b/src/xspice/icm/table/table2D/cfunc.mod @@ -29,6 +29,7 @@ AUTHORS MODIFICATIONS + 10 Aug 2018 Holger Vogt SUMMARY @@ -291,6 +292,26 @@ cnv_get_spice_value(char *str, /* IN - The value text e.g. 1.2K */ return OK; } +static void +cm_table2D_callback(ARGS, Mif_Callback_Reason_t reason) +{ + switch (reason) { + case MIF_CB_DESTROY: { + int i; + Local_Data_t *loc = STATIC_VAR (locdata); + if (loc->state->fp) + fclose(loc->state->fp); + free(loc->state); + for (i = 0; i < loc->iy; i++) + free(loc->table[i]); + free(loc->table); + free(loc); + break; + } + } +} + + /*============================================================================== @@ -380,6 +401,8 @@ cm_table2D(ARGS) /* structure holding parms, inputs, outputs, etc. */ size_t lTotalChars; /* Total characters read */ int interporder; /* order of interpolation for eno */ + CALLBACK = cm_table2D_callback; + /* allocate static storage for *loc */ STATIC_VAR (locdata) = calloc(1, sizeof(Local_Data_t)); loc = STATIC_VAR (locdata); @@ -594,10 +617,7 @@ cm_table2D(ARGS) /* structure holding parms, inputs, outputs, etc. */ /* fill table data into eno2 structure */ sf_eno2_set (loc->newtable, table_data /* data [n2][n1] */); - /* free all the emory allocated */ - // for (i = 0; i < iy; i++) - // free(table_data[i]); - // free(table_data); + /* free the file memory allocated */ free(cFile); free(cThisLine); } /* end of initialization "if (INIT == 1)" */ diff --git a/src/xspice/icm/table/table3D/cfunc.mod b/src/xspice/icm/table/table3D/cfunc.mod index 5bb2054f5..456cf1729 100644 --- a/src/xspice/icm/table/table3D/cfunc.mod +++ b/src/xspice/icm/table/table3D/cfunc.mod @@ -29,6 +29,7 @@ AUTHORS MODIFICATIONS + 10 Aug 2018 Holger Vogt SUMMARY @@ -297,6 +298,29 @@ cnv_get_spice_value(char *str, /* IN - The value text e.g. 1.2K */ return OK; } +static void +cm_table3D_callback(ARGS, Mif_Callback_Reason_t reason) +{ + switch (reason) { + case MIF_CB_DESTROY: { + int i, j; + Local_Data_t *loc = STATIC_VAR (locdata); + if (loc->state->fp) + fclose(loc->state->fp); + free(loc->state); + + for (i = 0; i < loc->iz; i++) { + for (j = 0; j < loc->iy; j++) + free(loc->table[i][j]); + free(loc->table[i]); + } + free(loc->table); + free(loc); + break; + } + } +} + /*============================================================================== @@ -312,7 +336,7 @@ MODIFICATIONS SUMMARY - This function implements 2D table code model. + This function implements 3D table code model. INTERFACES @@ -389,6 +413,8 @@ cm_table3D(ARGS) /* structure holding parms, inputs, outputs, etc. */ int lTableCount; /* Number of tables */ int interporder; /* order of interpolation for eno */ + CALLBACK = cm_table3D_callback; + /* allocate static storage for *loc */ STATIC_VAR (locdata) = calloc (1, sizeof(Local_Data_t)); loc = STATIC_VAR (locdata); @@ -631,10 +657,7 @@ cm_table3D(ARGS) /* structure holding parms, inputs, outputs, etc. */ sf_eno3_set(loc->newtable, table_data /* data [n3][n2][n1] */); - /* free all the emory allocated */ - // for (i = 0; i < iy; i++) - // free(table_data[i]); - // free(table_data); + /* free file memory allocated */ free(cFile); free(cThisLine); } /* end of initialization "if (INIT == 1)" */