diff --git a/wasm/plugin.go b/wasm/plugin.go index b63e0a4..39217c9 100644 --- a/wasm/plugin.go +++ b/wasm/plugin.go @@ -8,16 +8,12 @@ package wasm import "C" import ( - "reflect" "unsafe" ) func PtrToByte(ptr, size uint32) []byte { - var b []byte - s := (*reflect.SliceHeader)(unsafe.Pointer(&b)) - s.Len = uintptr(size) - s.Cap = uintptr(size) - s.Data = uintptr(ptr) + b := unsafe.Slice((*byte)(unsafe.Pointer(uintptr(ptr))), size) + return b }