Thanks for the links Ian, very informative :)

On Monday, January 23, 2017 at 5:43:56 PM UTC, Ian Lance Taylor wrote:
>
> On Mon, Jan 23, 2017 at 3:57 AM,  <pierspo...@gmail.com <javascript:>> 
> wrote: 
> > 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? 
>
> Basically, yes.  See 
> https://github.com/golang/proposal/blob/master/design/12416-cgo-pointers.md 
> and https://golang.org/issue/12416. 
>
> Ian 
>

-- 
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