3 ms·
> Go has moving memory so it generally means calling C SHOULD/WILL require a bunch of copying. I've been working on a few Go frontend to C libraries and resear
by 1_player 12y ago
> Go has moving memory so it generally means calling C SHOULD/WILL require a bunch of copying.
I've been working on a few Go frontend to C libraries and researching what's the exact memory model when calling C: Yes, Go has moving memory and you _shouldn't_ pass a Go pointer to C, and it's actively discouraged [1], but since many libraries just ignore that advice [2] for performance reason Go isn't currently AFAIK not moving any pointer passed through cgo.
That will probably be changed in Go 1.5+, I reckon an official post from the Go developer about the current and future state of C/Go memory interaction would help clarify this.
1: https://github.com/golang/go/issues/8310 https://github.com/golang/go/issues/8310
2: comment #31 of https://github.com/golang/go/issues/8310 https://github.com/golang/go/issues/8310