pub fn alloc(size: usize) -> Result<*mut u8, AllocationError>Expand description
A reasonably safe implementation of alloc.
- Memory allocated by this function must be freed by this crate’s
free. - Caller guarantees
freeis called before the returned pointer goes out of scope.
§Errors
Err(ArithmeticError)on integer overflow.Err(LayoutError)if the computed layout is invalid.Err(OutOfMemory)ifalloc()returns anullptr.
§Safety
This function is safe to call, as it produces a valid pointer. The data buffer being pointed to is, however, not initialized.