diff options
Diffstat (limited to 'src/ast.c')
-rw-r--r-- | src/ast.c | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -94,3 +94,20 @@ bool is_proper_list(ast_t *e) { return true; return false; } + +void ast_free(ast_t *e) { + if (e->cdr != NULL) { + ast_free(e->cdr); + } + if (e->car != NULL) { + ast_free(e->car); + } + + if (e->type == AST_ROOT) { + for (int i = 0; i < e->root_size; i++) { + ast_free(e->subnodes[i]); + } + } + + free(e); +} |