aboutsummaryrefslogtreecommitdiff
path: root/src/stdlib/stdlib.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-12-24 12:45:29 -0500
committerBruce Hill <bruce@bruce-hill.com>2025-12-24 12:52:48 -0500
commit649977aae7e5922f992cd69eb84da0a2db368580 (patch)
treee61d35b74d2551901cc8f3f034aca7da1f375a8c /src/stdlib/stdlib.c
parent88ccdab43c0a3ee53177e21a28724e496406a376 (diff)
Split out new()/gc logic from stdlib/util.h
Diffstat (limited to 'src/stdlib/stdlib.c')
-rw-r--r--src/stdlib/stdlib.c7
1 files changed, 6 insertions, 1 deletions
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) {