diff options
-rw-r--r-- | main.c | 1 | ||||
-rw-r--r-- | pc.y | 2 | ||||
-rw-r--r-- | tree.c | 11 | ||||
-rw-r--r-- | tree.h | 2 |
4 files changed, 16 insertions, 0 deletions
@@ -193,6 +193,7 @@ int main() assert(cur_scope); yyparse(); + free_scope(cur_scope); return 0; } @@ -97,6 +97,7 @@ program { set_ret_type($9); print_tree($9); + free_tree($4); } ; @@ -164,6 +165,7 @@ sub_prog_declaration { set_ret_type($4); print_tree($4); + free_tree($4); pop_scope(&cur_scope); } ; @@ -191,3 +191,14 @@ int spaces; } } + +void free_tree(t) +ptree *t; +{ + if (!t) + return; + + free_tree(t->l); + free_tree(t->r); + free(t); +} @@ -30,4 +30,6 @@ ptree* mkop(int, int, ptree*, ptree*); void update_type_info(ptree*, int); void set_ret_type(ptree*); +void free_tree(ptree*); + #endif |