From 0ccff2f626c0f43e4f7f7f7235285925a5c2e512 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Thu, 17 Oct 2013 14:29:37 +0900 Subject: [PATCH] free nested environment in codegen --- src/vm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/vm.c b/src/vm.c index cae8e09f..90be78f0 100644 --- a/src/vm.c +++ b/src/vm.c @@ -85,7 +85,7 @@ env_new(pic_state *pic, pic_value args, struct pic_env *env) struct pic_pair *cell; int i; - inner_env = (struct pic_env *)malloc(sizeof(struct pic_env)); + inner_env = (struct pic_env *)pic_alloc(pic, sizeof(struct pic_env)); inner_env->assoc = pic_nil_value(); inner_env->parent = env; @@ -420,6 +420,7 @@ pic_gen_lambda(pic_state *pic, pic_value obj, struct pic_env *env) } irep->code[irep->clen].insn = OP_RET; irep->clen++; + pic_free(pic, inner_env); #if VM_DEBUG printf("LAMBDA_%d:\n", pic->ilen);