diff options
Diffstat (limited to 'fptr_ast/struct.c')
-rw-r--r-- | fptr_ast/struct.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/fptr_ast/struct.c b/fptr_ast/struct.c index f22fae4..f33044a 100644 --- a/fptr_ast/struct.c +++ b/fptr_ast/struct.c @@ -51,6 +51,12 @@ static proc *gen_proc(int header, ...) #define gen_proc(...) gen_proc(0, __VA_ARGS__, NULL) +static void destroy_proc(proc *proc) +{ + vars_destroy(&proc->vars); + free(proc); +} + static void proc_set(proc *proc, char *name, intptr_t v) { foreach(vars, var, &proc->vars) { @@ -328,3 +334,24 @@ static intptr_t run(node *n) return 0; } + +/* destruction is easy as hell */ +static void destroy(node *n) +{ + if (!n) + return; + + destroy(n->n0); + destroy(n->n1); + destroy(n->n2); + destroy(n->n3); + + foreach(nodes, node, &n->nodes) { + destroy(*node); + } + + nodes_destroy(&n->nodes); + free(n); + + /* strings are not owned, nor are references to variables */ +} |