mirror of
https://github.com/vlang/v.git
synced 2025-09-15 15:32:27 +03:00
coroutines: only attempt to add/remove roots when GC is on.
This commit is contained in:
parent
f7058978a5
commit
77d45b1798
1 changed files with 6 additions and 2 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue