From: Jérémie Astor Date: Wed, 27 Apr 2022 09:33:00 +0000 (+0200) Subject: :art: handle ref objects in closures X-Git-Tag: nightly~275^2~33 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=b87ec06708b906cd5bd22b3852d14d531c8e5c21;p=gwion.git :art: handle ref objects in closures --- diff --git a/src/vm/closure.c b/src/vm/closure.c index 910e6331..8d888293 100644 --- a/src/vm/closure.c +++ b/src/vm/closure.c @@ -19,9 +19,12 @@ ANN Closure *new_closure(MemPool mp, const m_uint sz) { ANN void free_closure(Closure *a, const Gwion gwion) { const Map m = &a->m; - for (m_uint i = 0; i < map_size(m); ++i) - compound_release(gwion->vm->cleaner_shred, (Type)VKEY(m, i), - a->data + VVAL(m, i)); + for (m_uint i = 0; i < map_size(m); ++i) { + const Type t = (Type)VKEY(m, i); + const m_bit *data = tflag(t, tflag_ref) ? + (a->data + VVAL(m, i)) : *(m_bit**)(a->data + VVAL(m, i)); + compound_release(gwion->vm->cleaner_shred, t, data); + } map_release(m); _mp_free(gwion->mp, sizeof(Closure) + a->sz, a); }