On Thursday, March 1, 2018 at 1:16:45 PM UTC-5, Ian Lance Taylor wrote:
>
> On Thu, Mar 1, 2018 at 9:04 AM,  <[email protected] <javascript:>> 
> wrote: 
> > 
> > Is the KeepAlive call in the following example essential? and 
> sufficient? 
> > 
> > func ByteSlice2String(bs []byte) (str string) { 
> >     sliceHdr := (*reflect.SliceHeader)(unsafe.Pointer(&bs)) 
> >     strHdr := (*reflect.StringHeader)(unsafe.Pointer(&str)) 
> >     strHdr.Len = sliceHdr.Len 
> >     strHdr.Data = sliceHdr.Data 
> >     runtime.KeepAlive(&bs) // is this line essential? is it sufficient? 
> >     return 
> > } 
>
> Yes, I think it is both required and sufficient. 
>
> Ian 
>

Thanks for the confirmations.
 

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to