Memory allocated in Golang by C.CString() should be freed
Closed this issue · 1 comments
yushihang commented
c-polygonid/cmd/polygonid/polygonid.go
Line 422 in 5022edb
A function should be provided to be called by flutter/dart, to release the memory allocated by C.CString()
//PLGNFreeCString frees the memory allocated by Golang(using C.CString() ) for the given C string.
//It ensures a consistent and controlled memory management within Go code.
//export PLGNFreeCString
func PLGNFreeCString(str *C.char) {
// Note: We do not perform a null check here as C's free function can handle null safely.
C.free(unsafe.Pointer(str))
}
Like func PLGNFreeStatus(status *C.PLGNStatus) here:
c-polygonid/cmd/polygonid/polygonid.go
Lines 793 to 807 in 5022edb
yushihang commented