summaryrefslogtreecommitdiff
path: root/src/visitor.c
diff options
context:
space:
mode:
authorPreston Pan <preston@nullring.xyz>2023-01-08 15:39:19 -0800
committerPreston Pan <preston@nullring.xyz>2023-01-08 15:39:19 -0800
commit19367a27472a06634424e56c1eb21e4f53da4e9e (patch)
treefc58a08d36d451bdd1e7143a7358ac8a374355f7 /src/visitor.c
parent87d82ead963c24d84a4f6e417b96b9bf73d132bb (diff)
fixed invalid read; some memory leakage fixed but not completely
Diffstat (limited to 'src/visitor.c')
-rw-r--r--src/visitor.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/visitor.c b/src/visitor.c
index 65af934..bcea8e4 100644
--- a/src/visitor.c
+++ b/src/visitor.c
@@ -8,6 +8,8 @@
#include <stdlib.h>
#include <string.h>
+void visitor_reset() {}
+
visitor_t *init_visitor(parser_t *p) {
visitor_t *v = (visitor_t *)malloc(sizeof(visitor_t));
if (v == NULL)
@@ -535,8 +537,8 @@ ast_t *eval_list(visitor_t *v, ast_t *e) {
}
stack_push(v->stack_frame, stack_frame);
ast_t *res = eval_expr(v, function->cdr);
- stack_frame = stack_pop(v->stack_frame);
- /* hash_table_free(stack_frame); */
+ stack_pop(v->stack_frame);
+ hash_table_free_some(stack_frame);
return res;
}
@@ -572,3 +574,10 @@ void eval_error(visitor_t *v, ast_t *e) {
printf("ERROR: something went wrong with the visitor.\n");
exit(1);
}
+
+void visitor_free(visitor_t *v) {
+ ast_free(v->root);
+ hash_table_free(v->eval_table);
+ stack_free(v->stack_frame);
+ free(v);
+}