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

[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