Skip to content

Commit

Permalink
fix(module): correct go:wasmexport
Browse files Browse the repository at this point in the history
  • Loading branch information
knqyf263 committed Mar 6, 2025
1 parent 18f0e4a commit daa9dd5
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pkg/module/wasm/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,19 @@ func allocate(size uint32) uint32 {
return ptr
}

// go:wasmexport malloc
// malloc exposes a C-style malloc to the host.
// It returns an offset in WASM linear memory where the requested size is allocated.
func malloc(size uint32) uint32 {
//
//go:wasmexport malloc
func _malloc(size uint32) uint32 {
return allocate(size)
}

// go:wasmexport free
// free exposes a C-style free to the host.
// It deletes the slice from the allocations map so the memory can be reclaimed by the GC.
func free(ptr uint32, size uint32) {
//
//go:wasmexport free
func _free(ptr uint32, size uint32) {
delete(allocations, ptr)
}

Expand Down

0 comments on commit daa9dd5

Please sign in to comment.