Re: [go-nuts] [runtime] gostring question

2020-06-24 Thread keith . randall
Yes, we can't depend on the data at *p to remain constant. We need to snapshot it at the moment of the gostring call. On Tuesday, June 23, 2020 at 5:52:23 PM UTC-7, Kurtis Rader wrote: > > On Tue, Jun 23, 2020 at 5:32 PM Bill Morgan > wrote: > >> I'm a C programmer so maybe this is a dumb questi

Re: [go-nuts] [runtime] gostring question

2020-06-23 Thread Kurtis Rader
On Tue, Jun 23, 2020 at 5:32 PM Bill Morgan wrote: > I'm a C programmer so maybe this is a dumb question but, why does this > code in runtime/gostring.go allocate (rawstring) then copy data (memmove) > instead of just making the stringStruct.str point at the incoming data? > i.e. copy the pointer

[go-nuts] [runtime] gostring question

2020-06-23 Thread Bill Morgan
I'm a C programmer so maybe this is a dumb question but, why does this code in runtime/gostring.go allocate (rawstring) then copy data (memmove) instead of just making the stringStruct.str point at the incoming data? i.e. copy the pointer instead of allocating+copying data. func gostring(p *by