Hello!
In my code, I am creating an empty array on the stack, passing it to a C function (which mutates it), and returning the result. Is this safe behaviour? I didn't get an error, and the code works as expected; however, I'm not sure if this is by design or a coincidence...
I'm not familiar with the memory semantics here, so I'd appreciate if anyone could explain.
Here's an example of my use-case (c.populateArray is imported from C):
fn myFunc() [*c]const u8 {
const size = 8;
var arr: [size]u8 = .{0} ** size;
c.populateArray(&arr, size);
return &arr;
}
Thank you!
