Hello Folks,

Having some confusion for freeing memory allocated by C.String(). 
Filter_CSo my program is something like below.

A. Should we just call C.Free after line 6 for Filter_C directly or defer 
is just fine.
B. Currently we are expecting  the user of fetchdata() to free the  
Context_C, any alternates ?

test_go.go
=========

1  func fetchdata(x int, Filter String) (int32,String) {
2  var Context_C *C.char

3  Filter_C = C.String(Filter)
4  defer C.free(unsafe.Pointer(Filter_C))
5 
6  Context_C = C.Getdata(Filter_C)                    <<===== Context_C 
receives string from a malloc buffer
7
8  return 1,C.GoString(Context_C)
9  
10 }


Thanks

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to