Trait core::alloc::GlobalAlloc[][src]

pub unsafe trait GlobalAlloc {
    unsafe fn alloc(&self, layout: Layout) -> *mut Opaque;
unsafe fn dealloc(&self, ptr: *mut Opaque, layout: Layout); unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut Opaque { ... }
unsafe fn realloc(
        &self,
        ptr: *mut Opaque,
        layout: Layout,
        new_size: usize
    ) -> *mut Opaque { ... } }
🔬 This is a nightly-only experimental API. (allocator_api #32838)

the precise API and guarantees it provides may be tweaked slightly, especially to possibly take into account the types being stored to make room for a future tracing garbage collector

A memory allocator that can be registered to be the one backing std::alloc::Global though the #[global_allocator] attributes.

Required Methods

🔬 This is a nightly-only experimental API. (allocator_api #32838)

the precise API and guarantees it provides may be tweaked slightly, especially to possibly take into account the types being stored to make room for a future tracing garbage collector

Allocate memory as described by the given layout.

Returns a pointer to newly-allocated memory, or NULL to indicate allocation failure.

Safety

FIXME: what are the exact requirements?

🔬 This is a nightly-only experimental API. (allocator_api #32838)

the precise API and guarantees it provides may be tweaked slightly, especially to possibly take into account the types being stored to make room for a future tracing garbage collector

Deallocate the block of memory at the given ptr pointer with the given layout.

Safety

FIXME: what are the exact requirements? In particular around layout fit. (See docs for the Alloc trait.)

Provided Methods

🔬 This is a nightly-only experimental API. (allocator_api #32838)

the precise API and guarantees it provides may be tweaked slightly, especially to possibly take into account the types being stored to make room for a future tracing garbage collector

🔬 This is a nightly-only experimental API. (allocator_api #32838)

the precise API and guarantees it provides may be tweaked slightly, especially to possibly take into account the types being stored to make room for a future tracing garbage collector

Shink or grow a block of memory to the given new_size. The block is described by the given ptr pointer and layout.

Return a new pointer (which may or may not be the same as ptr), or NULL to indicate reallocation failure.

If reallocation is successful, the old ptr pointer is considered to have been deallocated.

Safety

new_size, when rounded up to the nearest multiple of old_layout.align(), must not overflow (i.e. the rounded value must be less than usize::MAX).

FIXME: what are the exact requirements? In particular around layout fit. (See docs for the Alloc trait.)

Implementors