cjson: FreeCStr

This commit is contained in:
xushiwei
2024-07-26 16:31:53 +08:00
parent 66a89a7d54
commit ae50511135
2 changed files with 10 additions and 1 deletions

View File

@@ -22,6 +22,9 @@ func main() {
mod.SetItem(c.Str("items"), syms) mod.SetItem(c.Str("items"), syms)
c.Printf(c.Str("%s\n"), mod.CStr()) cstr := mod.CStr()
c.Printf(c.Str("%s\n"), cstr)
cjson.FreeCStr(cstr)
mod.Delete() mod.Delete()
} }

View File

@@ -133,3 +133,9 @@ func (o *JSON) PrintUnformatted() *c.Char { return nil }
// //
// llgo:link (*JSON).PrintBuffered C.cJSON_PrintBuffered // llgo:link (*JSON).PrintBuffered C.cJSON_PrintBuffered
func (o *JSON) PrintBuffered(prebuffer c.Int, fmt c.Int) *c.Char { return nil } func (o *JSON) PrintBuffered(prebuffer c.Int, fmt c.Int) *c.Char { return nil }
//go:linkname Free C.cJSON_free
func Free(ptr unsafe.Pointer)
//go:linkname FreeCStr C.cJSON_free
func FreeCStr(*c.Char)