I am having trouble determining what variables need to be freed in GDNative. I have a function like this"
void function(godot_variant var) {
godot_string gs_var = api->godot_variant_as_string(&var);
godot_char_string gcs_var = api->godot_string_utf8(&gs_var);
const char *c_var = api->godot_char_string_get_data(&gcs_var);
}
Do these functions, godot_variant_as_string
, godot_string_utf8
, and godot_char_string_get_data
dynamically allocate memory? I don't think godot_char_string_get_data
dynamically allocates memory because its return type is const char *
, and the GLFWDemo on the GitHub site implies that godot_string_utf8
does dynamically allocate memory, whereas godot_variant_as_string
does not. However, that seems like a bizzare inconsistency to me. What about other GDNative functions, such as godot_string_to_upper
or godot_string_is_numeric
? Do all of these functions return dynamically allocated memory, do none of them, or is it some weird mix?