From 21d7c0efaf3cce4a518a0e6af946190d52113acc Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 17 Dec 2023 12:17:42 +0000 Subject: Add object as root before adding to list of objects --- runtime/src/gc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'runtime') diff --git a/runtime/src/gc.c b/runtime/src/gc.c index c7f50f11..c5738f63 100644 --- a/runtime/src/gc.c +++ b/runtime/src/gc.c @@ -111,14 +111,14 @@ void* shed__runtime__gc_alloc(size_t size, size_t children_offset, size_t childr sizeof(void*) * children_count ); - first = object; - // TODO: is it possible to leave adding the root to the caller, and avoid // having to add so many roots? (Since some values will immediately become a // descendant of a root.) shed__runtime__gc_push_root_gc_object(object); + first = object; + return object; } -- cgit v1.2.3