Skip to content

Commit

Permalink
jim.c: properly free cached callframes
Browse files Browse the repository at this point in the history
Commit 87ea45c removed the code to free cached callframes
when the interpreter is freed. Restore that code.

Signed-off-by: Steve Bennett <steveb@workware.net.au>
  • Loading branch information
msteveb committed Jan 27, 2014
1 parent cbd44b0 commit cc40852
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions jim.c
Expand Up @@ -5439,15 +5439,14 @@ Jim_Interp *Jim_CreateInterp(void)


void Jim_FreeInterp(Jim_Interp *i) void Jim_FreeInterp(Jim_Interp *i)
{ {
Jim_CallFrame *cf = i->framePtr, *prevcf; Jim_CallFrame *cf, *cfx;

Jim_Obj *objPtr, *nextObjPtr; Jim_Obj *objPtr, *nextObjPtr;


/* Free the call frames list - must be done before i->commands is destroyed */ /* Free the active call frames list - must be done before i->commands is destroyed */
while (cf) { for (cf = i->framePtr; cf; cf = cfx) {
prevcf = cf->parent; cfx = cf->parent;
JimFreeCallFrame(i, cf, JIM_FCF_FULL); JimFreeCallFrame(i, cf, JIM_FCF_FULL);
Jim_Free(cf);
cf = prevcf;
} }


Jim_DecrRefCount(i, i->emptyObj); Jim_DecrRefCount(i, i->emptyObj);
Expand Down Expand Up @@ -5507,6 +5506,14 @@ void Jim_FreeInterp(Jim_Interp *i)
objPtr = nextObjPtr; objPtr = nextObjPtr;
} }


/* Free the free call frames list */
for (cf = i->freeFramesList; cf; cf = cfx) {
cfx = cf->next;
if (cf->vars.table)
Jim_FreeHashTable(&cf->vars);
Jim_Free(cf);
}

/* Free the interpreter structure. */ /* Free the interpreter structure. */
Jim_Free(i); Jim_Free(i);
} }
Expand Down

0 comments on commit cc40852

Please sign in to comment.