Function alloc_zeroed

Source
pub unsafe fn alloc_zeroed(
    layout: Layout,
) -> Result<(NonNull<ScrapHeap>, NonNull<u8>), AllocError>
Expand description

Attempts to allocate zero-initialized memory using the thread-local scrap heap.

§Errors

Returns a pair of non-null pointers to the scrap heap and the allocated memory on success, or an AllocError if allocation fails.

§Safety

  • The caller must ensure proper usage and deallocation of the returned pointer.
  • This function may write zero bytes to uninitialized memory.