From 77d45b1798cd39e70571c029cffcfe82df417efb Mon Sep 17 00:00:00 2001 From: Joe Conigliaro Date: Fri, 27 Oct 2023 20:13:36 +1100 Subject: [PATCH] coroutines: only attempt to add/remove roots when GC is on. --- vlib/coroutines/coroutines.v | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/vlib/coroutines/coroutines.v b/vlib/coroutines/coroutines.v index 98f36f862e..57880f86eb 100644 --- a/vlib/coroutines/coroutines.v +++ b/vlib/coroutines/coroutines.v @@ -25,13 +25,17 @@ fn init() { alloc := fn (_ voidptr, stack_size int) voidptr { unsafe { stack_ptr := malloc(stack_size) - C.GC_add_roots(stack_ptr, charptr(stack_ptr) + stack_size) + $if gcboehm { + C.GC_add_roots(stack_ptr, charptr(stack_ptr) + stack_size) + } return stack_ptr } } dealloc := fn (_ voidptr, stack_ptr voidptr, stack_size int) { unsafe { - C.GC_remove_roots(stack_ptr, charptr(stack_ptr) + stack_size) + $if gcboehm { + C.GC_remove_roots(stack_ptr, charptr(stack_ptr) + stack_size) + } free(stack_ptr) } }