Browse Source

plug a memory leak by CALLBACK,

deleting locally malloced memory
pre-master-46
Holger Vogt 6 years ago
parent
commit
29b2799c22
  1. 23
      src/xspice/icm/analog/pwl/cfunc.mod

23
src/xspice/icm/analog/pwl/cfunc.mod

@ -224,6 +224,25 @@ NON-STANDARD FEATURES
==============================================================================*/
static void
cm_pwl_callback(ARGS, Mif_Callback_Reason_t reason)
{
switch (reason) {
case MIF_CB_DESTROY: {
double *last_x_value = STATIC_VAR (last_x_value);
double *x = STATIC_VAR (x);
double *y = STATIC_VAR (y);
free(last_x_value);
free(x);
free(y);
STATIC_VAR (last_x_value) = NULL;
STATIC_VAR (x) = NULL;
STATIC_VAR (y) = NULL;
break;
}
}
}
/*=== CM_PWL ROUTINE ================*/
void cm_pwl(ARGS) /* structure holding parms,
@ -250,7 +269,9 @@ void cm_pwl(ARGS) /* structure holding parms,
double test; /* temp storage variable for limit testing */
Mif_Complex_t ac_gain;
CALLBACK = cm_pwl_callback;
char *allocation_error="\n***ERROR***\nPWL: Allocation calloc failed!\n";
char *limit_error="\n***ERROR***\nPWL: Violation of 50% rule in breakpoints!\n";

Loading…
Cancel
Save