Skip to content

Commit 77d45b1

Browse files
coroutines: only attempt to add/remove roots when GC is on.
1 parent f705897 commit 77d45b1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

vlib/coroutines/coroutines.v

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,17 @@ fn init() {
2525
alloc := fn (_ voidptr, stack_size int) voidptr {
2626
unsafe {
2727
stack_ptr := malloc(stack_size)
28-
C.GC_add_roots(stack_ptr, charptr(stack_ptr) + stack_size)
28+
$if gcboehm {
29+
C.GC_add_roots(stack_ptr, charptr(stack_ptr) + stack_size)
30+
}
2931
return stack_ptr
3032
}
3133
}
3234
dealloc := fn (_ voidptr, stack_ptr voidptr, stack_size int) {
3335
unsafe {
34-
C.GC_remove_roots(stack_ptr, charptr(stack_ptr) + stack_size)
36+
$if gcboehm {
37+
C.GC_remove_roots(stack_ptr, charptr(stack_ptr) + stack_size)
38+
}
3539
free(stack_ptr)
3640
}
3741
}

0 commit comments

Comments
 (0)