plug a memory leak by CALLBACK,

deleting locally malloced memory
This commit is contained in:
Holger Vogt 2019-12-07 14:53:08 +01:00
parent e89a92f944
commit 29b2799c22
1 changed files with 22 additions and 1 deletions

View File

@ -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";