Skip to main content

PlatformAlloc

Trait PlatformAlloc 

Source
pub trait PlatformAlloc {
    // Required methods
    fn alloc(size: usize) -> *mut c_void;
    fn realloc(ptr: *mut c_void, size: usize) -> *mut c_void;
    fn dealloc(ptr: *mut c_void);

    // Provided methods
    fn heap_used_bytes() -> usize { ... }
    fn heap_total_bytes() -> usize { ... }
}
Expand description

Heap memory allocation.

Required Methods§

Source

fn alloc(size: usize) -> *mut c_void

Allocate size bytes. Returns null on failure.

Source

fn realloc(ptr: *mut c_void, size: usize) -> *mut c_void

Reallocate a previously allocated block. Returns null on failure.

Source

fn dealloc(ptr: *mut c_void)

Free a previously allocated block.

Provided Methods§

Source

fn heap_used_bytes() -> usize

Phase 230 Z5 / RFC-0034 D7 — bytes currently allocated from the platform heap. The true unified figure where the platform owns one kernel heap shared by the C side (alloc) and the Rust #[global_allocator]. Default 0 = “unknown / not instrumented”.

Source

fn heap_total_bytes() -> usize

Total managed heap size in bytes (used + free), or 0 if unknown.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl PlatformAlloc for CffiPlatform

Implementors§