What happens to return string pointer from file handler #521
Closed
OsakiTsukiko
started this conversation in
General
Replies: 1 comment 2 replies
-
Thank you for pointing this out. It seems the Zig example is missing some important comments. I will update it soon. However, if you allocate memory using Zig Example: fn my_files_handler(filename: []const u8) ?[]const u8 {
const buffer = webui.malloc(1024 * 4);
return buffer; // WebUI will automatically free buffer
} |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am using webui-zig and the signature for the file handler is
fn my_files_handler(filename: []const u8) ?[]u8
and it seems to not be freed. Why is the return value not freed afterward? There is little purpose in having a filehandle that only returns static strings. Also, I can not see how this works in C, wouldn't local variables go out of scope? How do you send a char pointer to a locally defined variable?Beta Was this translation helpful? Give feedback.
All reactions