The doc for cgo states ...

"Go code may pass a Go pointer to C provided the Go memory to which it 
points does not contain any Go pointers. The C code must preserve this 
property: it must not store any Go pointers in Go memory, even temporarily. 
When passing a pointer to a field in a struct, the Go memory in question is 
the memory occupied by the field, not the entire struct. When passing a 
pointer to an element in an array or slice, the Go memory in question is 
the entire array or the entire backing array of the slice.

Why is this? Is it because go only keeps track of the pointers that are 
direct arguments to a cgo call.  So if for instance a struct containing the 
only pointer to some value is passed to cgo then go loses track of that 
reference and the memory pointed at will be up for garbage collection?

Thanks,

Piers



-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to