Skip to content

Commit

Permalink
Do not free memory that needs to persist in host
Browse files Browse the repository at this point in the history
Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com>
  • Loading branch information
gmlewis committed Jun 15, 2024
1 parent 095ac11 commit 25146cc
Showing 1 changed file with 0 additions and 5 deletions.
5 changes: 0 additions & 5 deletions extism_pdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}
Expand All @@ -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)
}
Expand Down

0 comments on commit 25146cc

Please sign in to comment.