From 192ca6e3190714a888a8d585a1113eaffe0b7d9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rich=CE=9Brd?= Date: Tue, 31 Aug 2021 15:17:44 -0400 Subject: [PATCH] feat: add function to free memory (#2344) --- cmd/library/main.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cmd/library/main.go b/cmd/library/main.go index d405f7b85..400aebe4d 100644 --- a/cmd/library/main.go +++ b/cmd/library/main.go @@ -33,6 +33,12 @@ func main() { } } + // To free memory allocated to strings + output += "//export Free\n" + output += "func Free (param unsafe.Pointer){\n" + output += "C.free(param);\n" + output += "}\n" + fmt.Println(output) } @@ -135,5 +141,6 @@ func handleFile(parsedAST *ast.File) string { } output += handleFunction(name, obj.Decl.(*ast.FuncDecl)) } + return output }