diff options
Diffstat (limited to 'src/stdlib/stdlib.c')
| -rw-r--r-- | src/stdlib/stdlib.c | 7 |
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) { |
