From 649977aae7e5922f992cd69eb84da0a2db368580 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Wed, 24 Dec 2025 12:45:29 -0500 Subject: Split out new()/gc logic from stdlib/util.h --- src/stdlib/stdlib.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/stdlib/stdlib.c') diff --git a/src/stdlib/stdlib.c b/src/stdlib/stdlib.c index 7b038dac..7ed18af1 100644 --- a/src/stdlib/stdlib.c +++ b/src/stdlib/stdlib.c @@ -328,7 +328,12 @@ typedef struct cleanup_s { static cleanup_t *cleanups = NULL; public -void tomo_at_cleanup(Closure_t fn) { cleanups = new (cleanup_t, .cleanup_fn = fn, .next = cleanups); } +void tomo_at_cleanup(Closure_t fn) { + cleanup_t *new_cleanup = GC_MALLOC(sizeof(cleanup_t)); + new_cleanup->cleanup_fn = fn; + new_cleanup->next = cleanups; + cleanups = new_cleanup; +} public void tomo_cleanup(void) { -- cgit v1.2.3