mirror of
https://github.com/vlang/v.git
synced 2025-09-09 23:39:39 -04:00
coroutines: only attempt to add/remove roots when GC is on.
This commit is contained in:
parent
f7058978a5
commit
77d45b1798
@ -25,13 +25,17 @@ fn init() {
|
|||||||
alloc := fn (_ voidptr, stack_size int) voidptr {
|
alloc := fn (_ voidptr, stack_size int) voidptr {
|
||||||
unsafe {
|
unsafe {
|
||||||
stack_ptr := malloc(stack_size)
|
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
|
return stack_ptr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dealloc := fn (_ voidptr, stack_ptr voidptr, stack_size int) {
|
dealloc := fn (_ voidptr, stack_ptr voidptr, stack_size int) {
|
||||||
unsafe {
|
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)
|
free(stack_ptr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user