From: fennecdjay Date: Wed, 26 Oct 2022 11:49:49 +0000 (+0200) Subject: :art: Improve code->instr X-Git-Tag: nightly~207^2~117 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=414129d0;p=gwion.git :art: Improve code->instr --- 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;