From 25146ccfb8474022dd4296bf55d4f9c36eeae6f7 Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Sat, 15 Jun 2024 00:46:46 -0400 Subject: [PATCH] Do not free memory that needs to persist in host Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- extism_pdk.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/extism_pdk.go b/extism_pdk.go index 3410791..a9afd3f 100644 --- a/extism_pdk.go +++ b/extism_pdk.go @@ -154,7 +154,6 @@ func SetErrorString(err string) { func GetConfig(key string) (string, bool) { mem := AllocateBytes([]byte(key)) - defer mem.Free() offset := extism_config_get(mem.offset) clength := extism_length(offset) @@ -205,10 +204,8 @@ func GetVar(key string) []byte { func SetVar(key string, value []byte) { keyMem := AllocateBytes([]byte(key)) - defer keyMem.Free() valMem := AllocateBytes(value) - defer valMem.Free() extism_var_set(keyMem.offset, valMem.offset) } @@ -230,13 +227,11 @@ func GetVarInt(key string) int { func SetVarInt(key string, value int) { keyMem := AllocateBytes([]byte(key)) - defer keyMem.Free() bytes := make([]byte, 8) binary.LittleEndian.PutUint64(bytes, uint64(value)) valMem := AllocateBytes(bytes) - defer valMem.Free() extism_var_set(keyMem.offset, valMem.offset) }