From: Jérémie Astor Date: Fri, 23 Apr 2021 17:18:09 +0000 (+0200) Subject: :bomb: Fix effect leaks X-Git-Tag: nightly~722 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=0183cb17beb22528b2a6cbe4f4b1c4154932c302;p=gwion.git :bomb: Fix effect leaks --- diff --git a/src/import/import_oper.c b/src/import/import_oper.c index 1b48f8e4..687d215f 100644 --- a/src/import/import_oper.c +++ b/src/import/import_oper.c @@ -30,7 +30,7 @@ ANN2(1) static inline Type gwi_get_type(const Gwi gwi, const m_str str) { return str ? _get_type(gwi, str) : NULL; } -ANN2(1,2) static int import_op(const Gwi gwi, const struct OperCK* op, +ANN2(1,2) static int import_op(const Gwi gwi, struct OperCK*const op, const f_instr f) { const Type lhs = gwi_get_type(gwi, op->lhs), rhs = gwi_get_type(gwi, op->rhs), @@ -38,7 +38,9 @@ ANN2(1,2) static int import_op(const Gwi gwi, const struct OperCK* op, const struct Op_Func opfunc = { .ck=op->ck, .em=op->em, .effect = { .ptr=op->effect.ptr } }; const struct Op_Import opi = { .lhs=lhs, .rhs=rhs, .ret=ret, .func=&opfunc, .data=(uintptr_t)f, .pos=gwi->loc, .op=op->sym }; - return add_op(gwi->gwion, &opi); + const m_bool b = add_op(gwi->gwion, &opi); + op->effect.ptr = NULL; + return b; } diff --git a/src/parse/operator.c b/src/parse/operator.c index 50250aec..b9ad4b5a 100644 --- a/src/parse/operator.c +++ b/src/parse/operator.c @@ -91,6 +91,11 @@ ANN static M_Operator* new_mo(MemPool p, const struct Op_Import* opi) { if(opi->func) { mo->ck = opi->func->ck; mo->em = opi->func->em; + if(opi->func->effect.ptr) { +if(opi->lhs && opi->lhs != OP_ANY_TYPE) +puts(opi->lhs->name); + mo->effect.ptr = opi->func->effect.ptr; +} } return mo; }