func mallocList() *List {
const n = unsafe.Sizeof(List{})
p := C.malloc(C.ulong(n))
C.memset(p, C.int(n), 0)
return (*List)(p)
}
-j
--
On Sat, May 19, 2018 at 10:42 PM Max <massimiliano.ghilardi@gmail.com> wrote:
> The question is: is it allowed to take the unsafe.Pointer returned by C.malloc() and convert it to a pointer to a Go struct type?
See https://golang.org/pkg/unsafe/#Pointer-j
--
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 golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.