From 4a4b41dada4fa49a121a6184f3835efeaa6747f9 Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Sun, 23 Jun 2019 14:28:32 +0200 Subject: [PATCH] :art: use pools for tl2str --- include/env.h | 1 + src/lib/instr.c | 2 +- src/parse/check.c | 2 +- src/parse/type_decl.c | 8 +++----- util | 2 +- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/include/env.h b/include/env.h index 6dab0b09..bbd16cf3 100644 --- a/include/env.h +++ b/include/env.h @@ -48,6 +48,7 @@ ANN Map env_label(const Env); ANN Nspc env_nspc(const Env); ANN Type scan_type(const Env, const Type, const Type_Decl*); ANN Type type_decl_resolve(const Env, const Type_Decl*); +// tl2str returns a mp_alloced string ANEW ANN m_str tl2str(const Env, const Type_List); // in type_decl.c ANN m_bool compat_func(const __restrict__ Func_Def, const __restrict__ Func_Def); ANN Type known_type(const Env env, const Type_Decl*); diff --git a/src/lib/instr.c b/src/lib/instr.c index c75b63c6..7fa2239b 100644 --- a/src/lib/instr.c +++ b/src/lib/instr.c @@ -82,7 +82,7 @@ INSTR(GTmpl) { return; } } - xfree(tmpl_name); + free_mstr(emit->gwion->mp, tmpl_name); dt->def = f->def; const Func_Def def = from_base(emit->env, dt, f->value_ref->owner); if(!def) diff --git a/src/parse/check.c b/src/parse/check.c index 5544e35d..06444a7e 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -502,7 +502,7 @@ ANN static Func _find_template_match(const Env env, const Value v, const Exp_Cal break; } } - xfree(tmpl_name); + free_mstr(env->gwion->mp, tmpl_name); env_pop(env, scope); env->func = former; return m_func; diff --git a/src/parse/type_decl.c b/src/parse/type_decl.c index 9b88f18e..92dea09c 100644 --- a/src/parse/type_decl.c +++ b/src/parse/type_decl.c @@ -27,7 +27,7 @@ ANN static void td_info_run(const Env env, struct td_info* info) { do { m_str name = td2str(env, tl->td); text_add(&info->text, name); - xfree(name);// we can delete that after PoolizeStrings + free_mstr(env->gwion->mp, name); if(tl->next) text_add(&info->text, ","); } while((tl = tl->next)); @@ -48,15 +48,13 @@ ANEW ANN static m_str td2str(const Env env, const Type_Decl* td) { td_info_run(env, &info); text_add(&info.text, ">"); } - const m_str str = strdup(info.text.str); - text_release(&info.text); - return str; + return info.text.str; } ANEW ANN m_str tl2str(const Env env, Type_List tl) { struct td_info info = { .tl=tl, { .mp=env->gwion->mp} }; td_info_run(env, &info); - return strdup(info.text.str); + return info.text.str; } ANN static inline void* type_unknown(const Env env, const ID_List id) { diff --git a/util b/util index f3a4b121..776f7116 160000 --- a/util +++ b/util @@ -1 +1 @@ -Subproject commit f3a4b121af122f2b421cc1e58c812210305e2d1c +Subproject commit 776f7116cc6a1408870d8625b3dbbd992b214818 -- 2.43.0