summaryrefslogtreecommitdiff
path: root/src/program.c
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2014-11-09 16:11:38 -0500
committerAdrian Thurston <thurston@complang.org>2014-11-09 16:11:38 -0500
commit9a184d893dc837865cbf1ed42a8fbf34a7f88ac3 (patch)
tree2df025291b553a30d533962e4e95491c360dec47 /src/program.c
parenta65b15afebfd0e0edae68a0de2e94f9baae7d364 (diff)
downloadcolm-9a184d893dc837865cbf1ed42a8fbf34a7f88ac3.tar.gz
split tree free into tree and object free
Diffstat (limited to 'src/program.c')
-rw-r--r--src/program.c23
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 );