Struct

std::heap::Storage

source

Re-exported from alloc::heap::Storage.

struct Storage { ... }

The fallible allocation primitives, as static methods.

Zero-field policy types give static allocator methods a nominal receiver. They own no memory; allocation ownership remains exclusively in Uninit!.

Methods

method try_allocsource

fn try_alloc(size: usize) -> Result[Uninit!, AllocError] { ... }

A new uninitialized block of size bytes, or the allocation failure.

The fallible alloc. Takes no alignment: the block is whatever malloc returns. A block of no bytes (for an empty buffer) is one byte to malloc, so it is never null, as malloc(0) may be: a block's address goes into a Ref, which is never null.

method try_growsource

fn try_grow(u: Uninit!, new_size: usize) -> Result[Uninit!, (AllocError, Uninit!)] { ... }

u's block resized to new_size bytes, or the failure with u's block unchanged.

The fallible grow. The error arm hands the caller's own block back at its original extent -- never a fresh or null one. As in try_alloc, no bytes is one byte to realloc, which may free the block for none (realloc(p, 0)).