Skip to main content

alloc_raw

Function alloc_raw 

Source
pub unsafe fn alloc_raw(size: usize) -> *mut u8
Expand description

js_malloc: size bytes, uninitialised, with a header in front.

Answers a null pointer when the size cannot be represented or the allocator is out of memory, which is what the reference does rather than aborting: a script asking for 2^60 bytes must get a RangeError, not a dead process.

ยงSafety

The answer must be released exactly once with free_raw, and the whole HEADER_SIZE + size range is writable until then.