Re: [go-nuts] Using a defer func() closure to call c.free

2018-10-11 Thread Nathan Davies
Ok, that's an interesting line of investigation - I'll take a look into that and let you know if I find anything. Thanks Nathan On Thu, 11 Oct 2018 at 13:04, Robert Engels wrote: > It is not necessarily the open doc that is freeing the memory, could be > the close doc as well - meaning it needs

Re: [go-nuts] Using a defer func() closure to call c.free

2018-10-11 Thread Robert Engels
It is not necessarily the open doc that is freeing the memory, could be the close doc as well - meaning it needs the file and opt reference while it is open. Probably not file, but possible opt. The other thing are you sure that the opt doesn’t contain a reference that is freed to early... > On

Re: [go-nuts] Using a defer func() closure to call c.free

2018-10-11 Thread ndavies
Hi, That was at least a working theory there for a while; that perhaps the open document was doing some freeing of the memory before it returned. The reason we discounted that was some docs the defer func() free works fine. It could be a weird bug in that library, and I'm still considering tha

Re: [go-nuts] Using a defer func() closure to call c.free

2018-10-11 Thread Robert Engels
Are you sure the document is not doing the free of the file and the opt when it is destroyed? It might need those references beyond the function scope. > On Oct 11, 2018, at 3:52 AM, ndav...@turnitin.com wrote: > > > package main > > /* > #cgo CFLAGS: -g -Wall -I/usr/local/include > #cgo LDFL

Re: [go-nuts] Using a defer func() closure to call c.free

2018-10-11 Thread ndavies
package main /* #cgo CFLAGS: -g -Wall -I/usr/local/include #cgo LDFLAGS: -L/usr/local/lib -lm -lstdc++ #include #include #include #include // tet_pcos_get_string wraps the TET_pcos_get_string so we can use it in Go, cgo does not support // variadic args, this is the solution char* str_add(c

Re: [go-nuts] Using a defer func() closure to call c.free

2018-10-11 Thread Jan Mercl
On Thu, Oct 11, 2018 at 10:15 AM wrote: > What I am wondering is why the closure approach does not work? ISTM it should work. Please post a full, standalone reproduction code here or at the issue tracker, thanks. -- -j -- You received this message because you are subscribed to the Google G

[go-nuts] Using a defer func() closure to call c.free

2018-10-11 Thread ndavies
Hi all, Apologies if this has already been asked and answered elsewhere, I took a look and couldn't find anything. I have a simple cgo program that looks a little something like: func doTheCGo(){ f := C.CString("/path/to/file.ext") o := C.CString("useful values for c call") defer f