Bhavya Bhatt
12/06/2024, 4:32 PMpin
the allocation until host sets the data and kotlin collects the bytes and then unpin
the allocation ?Igor Yakovlev
12/06/2024, 8:59 PMDaniel
12/07/2024, 12:57 AM@WasmImport
SetReturnValue(pointer)
@WasmExport
YourFn() {
let value = …
withScopedMemoryAllocator(allocator {
let pointer = allocator.allocate(10)
pointer.write(value.toByte())
//safely pass data to native
SetReturnValue(pointer.address)
}
// It would not be safe to use pointer out here since the memory has been collected.
}
Bhavya Bhatt
12/07/2024, 6:12 AM