When native code returns a struct or boxed type with transfer-ownership="none", the struct should be copied. For boxed types, use g_boxed_copy; for other types, either use the copy-func annotation (often missing) or heuristics (look for a copy or ref function), and register it with the MemoryCleaner so the copy will be disposed later.
Without this, the struct can be disposed somewhere else and when Java code then tries to use it, the program will segfault.
When native code returns a struct or boxed type with
transfer-ownership="none"
, the struct should be copied. For boxed types, useg_boxed_copy
; for other types, either use thecopy-func
annotation (often missing) or heuristics (look for acopy
orref
function), and register it with the MemoryCleaner so the copy will be disposed later.Without this, the struct can be disposed somewhere else and when Java code then tries to use it, the program will segfault.