Trait haz_alloc_core::backend::Backend
source · pub unsafe trait Backend {
type Mutex: Mutex;
// Required methods
fn mreserve(ptr: *mut u8, size: usize) -> *mut u8;
unsafe fn mcommit(ptr: *mut u8, size: usize) -> bool;
unsafe fn mdecommit(ptr: *mut u8, size: usize);
unsafe fn munreserve(ptr: *mut u8, size: usize);
fn pagesize() -> usize;
unsafe fn tls_attach(callback: *const TlsCallback);
}
Expand description
This trait contains external functions that are provided by the user in order for the library to perform system actions such as page allocation.
Safety
The implementation must make sure the functions in the trait behave properly.
Required Associated Types§
Required Methods§
sourcefn mreserve(ptr: *mut u8, size: usize) -> *mut u8
fn mreserve(ptr: *mut u8, size: usize) -> *mut u8
Reserve the block of memory starting at ptr
if ptr
is not null and
with size
.
If ptr
is null, the block of memory can start at an offset determined
by the system.
If the function fails null is returned.
sourceunsafe fn mcommit(ptr: *mut u8, size: usize) -> bool
unsafe fn mcommit(ptr: *mut u8, size: usize) -> bool
Commit memory starting at ptr
with size size
.
If the function fails null is returned.
Safety
The memory must be reserved.
sourceunsafe fn munreserve(ptr: *mut u8, size: usize)
unsafe fn munreserve(ptr: *mut u8, size: usize)
Unreserve memory starting at ptr
with size size
.
Safety
The memory must be reserved.
The size must be equals to the same size used for reserving.
sourceunsafe fn tls_attach(callback: *const TlsCallback)
unsafe fn tls_attach(callback: *const TlsCallback)
Attach the given callback to this thread, running it when the thread is destroyed.
Safety
The callback must be #[thread_local].