Re-exported from alloc::heap::HeapAllocator.
struct HeapAllocator { ... }
Static allocator methods backed by the host heap. This policy value owns no storage; returned Uninit! values hold allocation ownership.
Methods
method allocsource
fn alloc(size: usize) -> Uninit! { ... }
A new uninitialized block of size bytes, aborting when the allocation fails.
Storage::try_alloc, aborting on failure. Most allocations in the library (arena chunks, hash entries, Owned!::new, ...) use this form, so they need no error channel.
The Err arm aborts; its tail still has to be an Uninit!. It builds the null Uninit! directly rather than through adopt_raw, whose precondition (a live allocation) the null pointer does not meet. Constructing the literal in its own module makes no such claim.
method growsource
fn grow(u: Uninit!, new_size: usize) -> Uninit! { ... }
u's block resized to new_size bytes, aborting when that fails.
Storage::try_grow, aborting on failure. The Err arm needs no invented value: try_grow hands the caller's block back.
method dropsource
fn drop(u: Uninit!) -> () { ... }
Frees the block u owns.
method adopt_rawsource
unsafe fn adopt_raw(p: *u8) -> Uninit! { ... }
Turns an address back into an owner.
Caller: p is the base address of a single live allocation obtained from malloc/realloc (directly or through this module's alloc/grow), for which no other Uninit! exists -- i.e. an address the caller itself obtained from Uninit!::into_raw (or carried along a single-owner path), never a copy, a sub-range, or an address from another allocator.
Records extent: 0usize, meaning "not recorded", which is indistinguishable from a real zero-byte allocation. A caller that still knows the size should use adopt_raw_sized.
method adopt_raw_sizedsource
unsafe fn adopt_raw_sized(p: *u8, extent: usize) -> Uninit! { ... }
adopt_raw, for a caller that still knows the block's size, so the extent survives a round trip (as in alloc::owned::Allocation!::release).
Caller: as for adopt_raw, and extent is the size most recently requested for that block.