From: fennecdjay Date: Sun, 23 Jun 2019 12:44:02 +0000 (+0200) Subject: :art: Poolize Code->name X-Git-Tag: nightly~2397 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=8ad5db91b25bf8afd926651719c758a8092b219e;p=gwion.git :art: Poolize Code->name --- diff --git a/include/vm.h b/include/vm.h index 3c10ea91..0106d504 100644 --- a/include/vm.h +++ b/include/vm.h @@ -77,7 +77,7 @@ ANEW VM* new_vm(MemPool, const m_bool); ANN void free_vm(VM* vm); ANN void vm_add_shred(const VM* vm, const VM_Shred shred)__attribute__((hot)); ANN void vm_remove(const VM* vm, const m_uint index)__attribute__((hot)); -ANN m_str code_name_set(const m_str, const m_str); +ANN m_str code_name_set(MemPool p, const m_str, const m_str); ANN m_str code_name(const m_str, const m_bool); ANN uint32_t gw_rand(uint32_t s[2]); ANN void gw_seed(uint32_t s[2], const uint64_t); diff --git a/src/emit/emit.c b/src/emit/emit.c index 1eabddde..9ab3b8ac 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -99,7 +99,7 @@ ANN static m_bool emit_func_def(const Emitter emit, const Func_Def func_def); ANEW static Code* new_code(const Emitter emit, const m_str name) { Code* code = mp_calloc(emit->gwion->mp, Code); - code->name = code_name_set(name, emit->env->name); + code->name = code_name_set(emit->gwion->mp, name, emit->env->name); vector_init(&code->instr); vector_init(&code->stack_break); vector_init(&code->stack_cont); @@ -114,7 +114,7 @@ ANN static void free_code(MemPool p, Code* code) { vector_release(&code->stack_cont); vector_release(&code->stack_return); free_frame(p, code->frame); - xfree(code->name); + free_mstr(p, code->name); mp_free(p, Code, code); } diff --git a/src/vm/vm_name.c b/src/vm/vm_name.c index 458fe63d..e16c0c25 100644 --- a/src/vm/vm_name.c +++ b/src/vm/vm_name.c @@ -4,9 +4,9 @@ #include "gwion_util.h" #include "gwion_ast.h" -m_str code_name_set(const m_str name, const m_str file) { +m_str code_name_set(MemPool p, const m_str name, const m_str file) { const size_t len = strlen(name) + strlen(file) + 2; - m_str str = (const m_str)xcalloc(1, len); + m_str str = (const m_str)_mp_malloc(p, len); sprintf(str, "%s$%s", name, file); return str; }