pub fn alloc(size: usize) -> Result<*mut u8, AllocationError>Expand description
A reasonably safe implementation of alloc.
Allocates a buffer of size bytes and returns a pointer to it. The buffer is
aligned to crate::HEADER_SIZE (16) bytes and is not initialized. alloc(0)
succeeds and returns a valid pointer to a zero-sized buffer.
Every returned pointer, including the zero-sized case, must eventually be released
with crate::free or crate::realloc; otherwise the allocation leaks.
ยงErrors
Err(ArithmeticError)on integer overflow.Err(LayoutError)if the computed layout is invalid.Err(OutOfMemory)if the underlying allocator returns a null pointer.