alloc

abstract val alloc: WasmAlloc(source)

Allocates n bytes of memory from the WASM heap and returns the address of the first byte in the block. alloc() throws a WasmAllocError if allocation fails. If non-thowing allocation is required, use alloc.impl(n), which returns a WASM NULL pointer (the integer 0) if allocation fails.

Note that memory allocated this way is not automatically zeroed out. In practice that has not proven to be a problem (in JS, at least) because memory is only explicitly allocated when it has a specific use and will be populated by the code which allocates it.