From 0908a71ac806d1a881abd9a27014413bab256930 Mon Sep 17 00:00:00 2001 From: Leo Tenenbaum Date: Mon, 4 May 2020 11:49:29 -0400 Subject: fixed bug with f(f(x)) solution --- allocator.c | 2 +- eval.c | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/allocator.c b/allocator.c index 98005ef..a731928 100644 --- a/allocator.c +++ b/allocator.c @@ -25,7 +25,7 @@ static void *err_malloc(size_t bytes); static void *err_calloc(size_t n, size_t sz); static void *err_realloc(void *prev, size_t new_size); #ifdef TOC_DEBUG -#define NO_ALLOCATOR 1 /* useful for debugging; valgrind checks writing past the end of a malloc, but that won't work with an allocator */ +//#define NO_ALLOCATOR 1 /* useful for debugging; valgrind checks writing past the end of a malloc, but that won't work with an allocator */ #endif /* number of bytes a page hold, not including the header */ #define PAGE_BYTES (16384 - sizeof(Page)) diff --git a/eval.c b/eval.c index e14e333..0271fb0 100644 --- a/eval.c +++ b/eval.c @@ -1460,7 +1460,6 @@ static Status eval_expr(Evaluator *ev, Expression *e, Value *v) { Declaration *params = fn->params; Expression *arg = e->call.arg_exprs; /* @OPTIM: figure out how much memory parameters use, then allocate that much space (possibly with alloca)? */ - Value **to_free = NULL; arr_foreach(params, Declaration, p) { int idx = 0; bool multiple_idents = arr_len(p->idents) > 1; @@ -1489,7 +1488,6 @@ static Status eval_expr(Evaluator *ev, Expression *e, Value *v) { } } arr_add(p->val_stack, pval); - arr_add(to_free, pval); } arr_foreach(fn->ret_decls, Declaration, d) { @@ -1552,8 +1550,6 @@ static Status eval_expr(Evaluator *ev, Expression *e, Value *v) { } arr_foreach(fn->params, Declaration, p) decl_remove_val(p); - arr_foreach(to_free, ValuePtr, p) - free(*p); arr_foreach(fn->ret_decls, Declaration, d) decl_remove_val(d); } break; -- cgit v1.2.3