Skip to content

Commit 7180e57

Browse files
authored
chore: temporarily remove sdk ambiguity on memory frees (#40)
1 parent fe9942a commit 7180e57

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

extism_pdk.go

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ func OutputJSON(v any) error {
9999
}
100100

101101
mem := AllocateBytes(b)
102-
defer mem.Free()
102+
// TODO: coordinate replacement of call to free based on SDK alignment
103+
// defer mem.Free()
103104
OutputMemory(mem)
104105
return nil
105106
}
@@ -178,7 +179,8 @@ func SetError(err error) {
178179
// SetErrorString sets the host error string from `err`.
179180
func SetErrorString(err string) {
180181
mem := AllocateString(err)
181-
defer mem.Free()
182+
// TODO: coordinate replacement of call to free based on SDK alignment
183+
// defer mem.Free()
182184
extismErrorSet(mem.offset)
183185
}
184186

@@ -216,7 +218,8 @@ func LogMemory(level LogLevel, memory Memory) {
216218
// Log logs the provided UTF-8 string `s` on the host using the provided log `level`.
217219
func Log(level LogLevel, s string) {
218220
mem := AllocateString(s)
219-
defer mem.Free()
221+
// TODO: coordinate replacement of call to free based on SDK alignment
222+
// defer mem.Free()
220223

221224
LogMemory(level, mem)
222225
}
@@ -241,10 +244,12 @@ func GetVar(key string) []byte {
241244
// SetVar sets the host variable associated with `key` to the `value` byte slice.
242245
func SetVar(key string, value []byte) {
243246
keyMem := AllocateBytes([]byte(key))
244-
defer keyMem.Free()
247+
// TODO: coordinate replacement of call to free based on SDK alignment
248+
// defer keyMem.Free()
245249

246250
valMem := AllocateBytes(value)
247-
defer valMem.Free()
251+
// TODO: coordinate replacement of call to free based on SDK alignment
252+
// defer valMem.Free()
248253

249254
extismVarSet(keyMem.offset, valMem.offset)
250255
}
@@ -269,21 +274,24 @@ func GetVarInt(key string) int {
269274
// SetVarInt sets the host variable associated with `key` to the `value` int.
270275
func SetVarInt(key string, value int) {
271276
keyMem := AllocateBytes([]byte(key))
272-
defer keyMem.Free()
277+
// TODO: coordinate replacement of call to free based on SDK alignment
278+
// defer keyMem.Free()
273279

274280
bytes := make([]byte, 8)
275281
binary.LittleEndian.PutUint64(bytes, uint64(value))
276282

277283
valMem := AllocateBytes(bytes)
278-
defer valMem.Free()
284+
// TODO: coordinate replacement of call to free based on SDK alignment
285+
// defer valMem.Free()
279286

280287
extismVarSet(keyMem.offset, valMem.offset)
281288
}
282289

283290
// RemoveVar removes (and frees) the host variable associated with `key`.
284291
func RemoveVar(key string) {
285292
mem := AllocateBytes([]byte(key))
286-
defer mem.Free()
293+
// TODO: coordinate replacement of call to free based on SDK alignment
294+
// defer mem.Free()
287295
extismVarSet(mem.offset, 0)
288296
}
289297

0 commit comments

Comments
 (0)