2
gihnius 2013 年 12 月 2 日 我只是新手.
data := C.malloc(...) defer C.free(data) 如果 data 在fn 里面 malloc 就不知道了.... 为什么不在里面 free 呢? |
3
guotie 2013 年 12 月 2 日 要释放
C.free(data) |
5
wwwjfy 2013 年 12 月 4 日 不是高手,用过两天..
http://golang.org/cmd/cgo/ // Go string to C string // The C string is allocated in the C heap using malloc. // It is the caller's responsibility to arrange for it to be // freed, such as by calling C.free (be sure to include stdlib.h // if C.free is needed). |