xspice/icm/analog/file_source/cfunc.mod, use CALLBACK
to free() locally allocated memory and fclose() a local filestream
This commit is contained in:
parent
58874cc65e
commit
926ba4baaf
|
|
@ -138,6 +138,23 @@ NON-STANDARD FEATURES
|
|||
/*=== CM_FILESOURCE ROUTINE ===*/
|
||||
|
||||
|
||||
static void
|
||||
cm_filesource_callback(ARGS, Mif_Callback_Reason_t reason)
|
||||
{
|
||||
switch (reason) {
|
||||
case MIF_CB_DESTROY: {
|
||||
Local_Data_t *loc = STATIC_VAR (locdata);
|
||||
fclose(loc->state->fp);
|
||||
free(loc->state);
|
||||
free(loc->amplinterval);
|
||||
free(loc->timeinterval);
|
||||
free(loc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void cm_filesource(ARGS) /* structure holding parms, inputs, outputs, etc. */
|
||||
{
|
||||
int size = PORT_SIZE(out);
|
||||
|
|
@ -154,6 +171,8 @@ void cm_filesource(ARGS) /* structure holding parms, inputs, outputs, etc.
|
|||
|
||||
int i;
|
||||
|
||||
CALLBACK = cm_filesource_callback;
|
||||
|
||||
/*** allocate static storage for *loc ***/
|
||||
STATIC_VAR (locdata) = calloc (1 , sizeof ( Local_Data_t ));
|
||||
loc = STATIC_VAR (locdata);
|
||||
|
|
|
|||
Loading…
Reference in New Issue