From 2867678f99c1aad86b51a8ba5486ba2667c7f22e Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Tue, 28 Aug 2018 17:11:51 +0200 Subject: [PATCH] For unsetup de-allocate the memory that has been allocated locally in the code model during INIT --- src/xspice/mif/mifsetup.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/xspice/mif/mifsetup.c b/src/xspice/mif/mifsetup.c index c33ae850b..e10d89edd 100644 --- a/src/xspice/mif/mifsetup.c +++ b/src/xspice/mif/mifsetup.c @@ -532,6 +532,22 @@ MIFunsetup(GENmodel *inModel,CKTcircuit *ckt) tfree(here->state); tfree(here->conv); tfree(here->intgr); + + /* de-allocate the memory that has been allocated locally in the code model during INIT */ + if (here->callback) { + Mif_Private_t cm_data; + /* Prepare the structure to be passed to the code model */ + cm_data.num_conn = here->num_conn; + cm_data.conn = here->conn; + cm_data.num_param = here->num_param; + cm_data.param = here->param; + cm_data.num_inst_var = here->num_inst_var; + cm_data.inst_var = here->inst_var; + cm_data.callback = &(here->callback); + + here->callback(&cm_data, MIF_CB_DESTROY); + } + here->initialized = MIF_FALSE; } /* end for all instances */ }