diff options
Diffstat (limited to 'src/program.c')
-rw-r--r-- | src/program.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/program.c b/src/program.c index d1fbbf3d..01a1db31 100644 --- a/src/program.c +++ b/src/program.c @@ -233,7 +233,8 @@ void colm_run_program( Program *prg, int argc, const char **argv ) prg->argv = 0; } -Tree *colm_run_func( struct colm_program *prg, int frameId, const char **params, int paramCount ) +Tree *colm_run_func( struct colm_program *prg, int frameId, + const char **params, int paramCount ) { /* Make the arguments available to the program. */ prg->argc = 0; @@ -282,22 +283,26 @@ Tree *colm_run_func( struct colm_program *prg, int frameId, const char **params, return prg->returnVal; }; -int colm_delete_program( Program *prg ) +static void colm_clear_heap( Program *prg, Tree **sp ) { - Tree **sp = prg->stackRoot; - int exitStatus = prg->exitStatus; - - treeDownref( prg, sp, prg->returnVal ); - clearGlobal( prg, sp ); - /* Clear the heap. */ Kid *a = prg->heap; while ( a != 0 ) { Kid *next = a->next; - treeDownref( prg, sp, a->tree ); + objectDownref( prg, sp, a->tree ); kidFree( prg, a ); a = next; } +} + +int colm_delete_program( Program *prg ) +{ + Tree **sp = prg->stackRoot; + int exitStatus = prg->exitStatus; + + treeDownref( prg, sp, prg->returnVal ); + clearGlobal( prg, sp ); + colm_clear_heap( prg, sp ); treeDownref( prg, sp, prg->trueVal ); treeDownref( prg, sp, prg->falseVal ); |