Browse Source

add a callback to de-allocate the static variable p->element

pre-master-46
Holger Vogt 8 years ago
parent
commit
c4f8a02eb0
  1. 15
      src/xspice/icm/spice2poly/icm_spice2poly/cfunc.mod

15
src/xspice/icm/spice2poly/icm_spice2poly/cfunc.mod

@ -68,6 +68,20 @@ and function nxtpwr() performs the function of subroutine NXTPWR.
static double evterm(double x, int n);
static void nxtpwr(int *pwrseq, int pdim);
static void
cm_spice2poly_callback(ARGS, Mif_Callback_Reason_t reason)
{
switch (reason) {
case MIF_CB_DESTROY: {
Mif_Inst_Var_Data_t *p = STATIC_VAR_INST(acgains);
if(p->element) {
free(p->element);
p->element = NULL;
}
break;
}
}
}
@ -98,6 +112,7 @@ void spice2poly (ARGS)
/* array */
if(INIT) {
CALLBACK = cm_spice2poly_callback;
Mif_Inst_Var_Data_t *p = STATIC_VAR_INST(acgains);
p -> size = num_inputs;
p -> element = (Mif_Value_t *) malloc((size_t) num_inputs * sizeof(Mif_Value_t));

Loading…
Cancel
Save