Skip to main content

write_output

Function write_output 

Source
pub fn write_output(bytes: Vec<u8>) -> u64
Expand description

Leak bytes into linear memory and return the packed (ptr << 32) | len the host uses to read and later free it.

The buffer is shrunk to an exact-size allocation (capacity == len, align 1) so that the host’s dealloc(ptr, len) frees precisely the allocation it was given. Returning a Vec directly would leak its (possibly larger) capacity and make dealloc a size-mismatched free.