Trait rlsf::CAlloc [−][src]
pub unsafe trait CAlloc { fn allocate(&self, layout: Layout) -> Option<NonNull<u8>>; unsafe fn deallocate(&self, ptr: NonNull<u8>); unsafe fn reallocate(
&self,
ptr: NonNull<u8>,
new_layout: Layout
) -> Option<NonNull<u8>>; }
Expand description
Provides allocation functions modelled after the standard C and POSIX
allocation functions (e.g., malloc
, memalign
).
Note that this trait might require a less efficient implementation than
core::alloc::GlobalAlloc
. This applies to GlobalTlsf
.
Required methods
fn allocate(&self, layout: Layout) -> Option<NonNull<u8>>
[src]
fn allocate(&self, layout: Layout) -> Option<NonNull<u8>>
[src]Allocate a memory block.
Returns the starting address of the allocated memory block on success;
None
otherwise.
unsafe fn deallocate(&self, ptr: NonNull<u8>)
[src]
unsafe fn deallocate(&self, ptr: NonNull<u8>)
[src]Deallocate a previously allocated memory block.
Safety
ptr
must denote a memory block previously allocated by callingSelf::allocate
onself
.
unsafe fn reallocate(
&self,
ptr: NonNull<u8>,
new_layout: Layout
) -> Option<NonNull<u8>>
[src]
unsafe fn reallocate(
&self,
ptr: NonNull<u8>,
new_layout: Layout
) -> Option<NonNull<u8>>
[src]Shrink or grow a previously allocated memory block.
Returns the new starting address of the memory block on success;
None
otherwise.
Safety
ptr
must denote a memory block previously allocated by callingSelf::allocate
onself
.
Implementors
impl<Options: GlobalTlsfOptions> CAlloc for GlobalTlsf<Options>
[src]
impl<Options: GlobalTlsfOptions> CAlloc for GlobalTlsf<Options>
[src]This is supported on WebAssembly and non-target feature
atomics
, or Unix only.