Dang, I always figured that would be unsafe eventually.
I wonder, does this make stuff like this unsafe:
var thing C.thing; C.somefunc(&thing)
i.e. can stack address change now?
I wonder, does this make stuff like this unsafe:
var thing C.thing; C.somefunc(&thing)
i.e. can stack address change now?
Create memory in Go-land
Use memory in C-land
Dispose of reference to memory in Go-land
That becomes a bit problematic if the C-land use is for a long-running process - you need a go object that owns the memory that has a lifetime that (at least) matches the lifetime of the C code execution.To make things work, you have to allocate date used in C in C and pass Go variables only by value.