Skip to main content

host_alloc

Function host_alloc 

Source
pub fn host_alloc(len: u32) -> u32
Expand description

Allocate len bytes in the module’s linear memory and return the pointer as a u32. Returns 0 for a zero-length request.

Returns 0 (allocation failure) rather than panicking on an oversized request (len ≥ isize::MAX), and never hands out a truncated pointer: on a 64-bit host (e.g. a plugin’s own native test build) a real heap address does not fit in u32, so such an allocation is freed and 0 returned. On wasm32 every address fits, so that guard is inert.