From 414129d0b5ddd6a0e563577dda6ddef0a9d98cb1 Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Wed, 26 Oct 2022 13:49:49 +0200 Subject: [PATCH] :art: Improve code->instr --- src/emit/emit.c | 2 +- src/vm/vm_code.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/emit/emit.c b/src/emit/emit.c index 41b55be4..f213a2b6 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -245,7 +245,7 @@ ANEW static Code *new_code(const Emitter emit, const m_str name) { } ANN static void free_code(MemPool p, Code *code) { - vector_release(&code->instr); + if(code->instr.ptr) vector_release(&code->instr); vector_release(&code->stack_break); vector_release(&code->stack_cont); vector_release(&code->stack_return); diff --git a/src/vm/vm_code.c b/src/vm/vm_code.c index e8602b8c..c619f1b2 100644 --- a/src/vm/vm_code.c +++ b/src/vm/vm_code.c @@ -182,8 +182,8 @@ VM_Code new_vmcode(MemPool p, const Vector instr, const M_Vector live_values, VM_Code code = mp_calloc(p, VM_Code); code->name = mstrdup(p, name); if (instr) { - vector_init(&code->instr); - vector_copy2(instr, &code->instr); + code->instr.ptr = instr->ptr; + instr->ptr = NULL; code->bytecode = tobytecode(p, code); } if (live_values) code->live_values.ptr = live_values->ptr; -- 2.43.0