Sorry for late reply, thanks very much! I will have a try.
在 2017年8月18日星期五 UTC+8下午4:23:07,Konstantin Khomoutov写道:
>
> On Fri, Aug 18, 2017 at 10:39:29AM +0300, Konstantin Khomoutov wrote:
>
> [...]
> > There can't be easy answer to a question like this in C.
> > Consider:
> >
> > // This fu
On Fri, Aug 18, 2017 at 10:39:29AM +0300, Konstantin Khomoutov wrote:
[...]
> There can't be easy answer to a question like this in C.
> Consider:
>
> // This function clearly transfers the ownership of the memory
> // it returns to the caller.
> int* allocate(int n)
> {
> int *mem =
On Thu, Aug 17, 2017 at 06:50:42PM -0700, jianzhang...@gmail.com wrote:
> > > As the instruction
> > > of https://github.com/golang/go/wiki/cgo#turning-c-arrays-into-go-slices
> > > shows, the GC of Go will not release it.
> > > An example as the following, but I have a question about when and
Thanks your reply, you mean I should be release the memory of `theCArray`
in C side?
I still have some doubts, and I made a clearer example as the below, any
problem with it?
So, the memory of this tmpslice should be release by release the argv on C
side?
func GoStrings(length int, argv **C.ch
On Thu, Aug 17, 2017 at 03:32:28AM -0700, jianzhang...@gmail.com wrote:
> As the instruction
> of https://github.com/golang/go/wiki/cgo#turning-c-arrays-into-go-slices
> shows, the GC of Go will not release it.
> An example as the following, but I have a question about when and how to
> release
As the instruction
of https://github.com/golang/go/wiki/cgo#turning-c-arrays-into-go-slices
shows, the GC of Go will not release it.
An example as the following, but I have a question about when and how to
release this `slice`?
import "C"
import "unsafe"
...
var theCArray *C.YourType =