pub struct FlexTlsf<Source: FlexSource, FLBitmap, SLBitmap, const FLLEN: usize, const SLLEN: usize> { /* private fields */ }
Expand description
A wrapper of Tlsf
that automatically acquires fresh memory pools from
FlexSource
.
Implementations§
source§impl<Source: FlexSource, FLBitmap: BinInteger, SLBitmap: BinInteger, const FLLEN: usize, const SLLEN: usize> FlexTlsf<Source, FLBitmap, SLBitmap, FLLEN, SLLEN>
impl<Source: FlexSource, FLBitmap: BinInteger, SLBitmap: BinInteger, const FLLEN: usize, const SLLEN: usize> FlexTlsf<Source, FLBitmap, SLBitmap, FLLEN, SLLEN>
sourcepub fn source_ref(&self) -> &Source
pub fn source_ref(&self) -> &Source
Borrow the contained Source
.
sourcepub unsafe fn source_mut_unchecked(&mut self) -> &mut Source
pub unsafe fn source_mut_unchecked(&mut self) -> &mut Source
Mutably borrow the contained Source
.
Safety
The caller must not replace the Source
with another one or modify
any existing allocations in the Source
.
sourcepub fn allocate(&mut self, layout: Layout) -> Option<NonNull<u8>>
pub fn allocate(&mut self, layout: Layout) -> Option<NonNull<u8>>
Attempt to allocate a block of memory.
Returns the starting address of the allocated memory block on success;
None
otherwise.
Time Complexity
This method will complete in constant time (assuming Source
’s methods
do so as well).
sourcepub unsafe fn deallocate(&mut self, ptr: NonNull<u8>, align: usize)
pub unsafe fn deallocate(&mut self, ptr: NonNull<u8>, align: usize)
Deallocate a previously allocated memory block.
Time Complexity
This method will complete in constant time (assuming Source
’s methods
do so as well).
Safety
ptr
must denote a memory block previously allocated viaself
.- The memory block must have been allocated with the same alignment
(
Layout::align
) asalign
.
sourcepub unsafe fn allocation_usable_size(ptr: NonNull<u8>) -> usize
Available on crate feature unstable
only.
pub unsafe fn allocation_usable_size(ptr: NonNull<u8>) -> usize
unstable
only.Get the actual usable size of a previously allocated memory block.
Safety
ptr
must denote a memory block previously allocated via some instance ofSelf
.- The call must happen-before the deallocation or reallocation of the memory block.
sourcepub unsafe fn reallocate(
&mut self,
ptr: NonNull<u8>,
new_layout: Layout
) -> Option<NonNull<u8>>
pub unsafe fn reallocate( &mut self, ptr: NonNull<u8>, new_layout: Layout ) -> Option<NonNull<u8>>
Shrink or grow a previously allocated memory block.
Returns the new starting address of the memory block on success;
None
otherwise.
Time Complexity
Unlike other methods, this method will complete in linear time
(O(old_size)
), assuming Source
’s methods do so as well.
Safety
ptr
must denote a memory block previously allocated viaself
.- The memory block must have been allocated with the same alignment
(
Layout::align
) asnew_layout
.
Trait Implementations§
source§impl<Source: FlexSource + ConstDefault, FLBitmap: BinInteger, SLBitmap: BinInteger, const FLLEN: usize, const SLLEN: usize> ConstDefault for FlexTlsf<Source, FLBitmap, SLBitmap, FLLEN, SLLEN>
impl<Source: FlexSource + ConstDefault, FLBitmap: BinInteger, SLBitmap: BinInteger, const FLLEN: usize, const SLLEN: usize> ConstDefault for FlexTlsf<Source, FLBitmap, SLBitmap, FLLEN, SLLEN>
Initialization with a FlexSource
provided by ConstDefault::DEFAULT
source§impl<Source: Debug + FlexSource, FLBitmap: Debug, SLBitmap: Debug, const FLLEN: usize, const SLLEN: usize> Debug for FlexTlsf<Source, FLBitmap, SLBitmap, FLLEN, SLLEN>
impl<Source: Debug + FlexSource, FLBitmap: Debug, SLBitmap: Debug, const FLLEN: usize, const SLLEN: usize> Debug for FlexTlsf<Source, FLBitmap, SLBitmap, FLLEN, SLLEN>
source§impl<Source: FlexSource + Default, FLBitmap: BinInteger, SLBitmap: BinInteger, const FLLEN: usize, const SLLEN: usize> Default for FlexTlsf<Source, FLBitmap, SLBitmap, FLLEN, SLLEN>
impl<Source: FlexSource + Default, FLBitmap: BinInteger, SLBitmap: BinInteger, const FLLEN: usize, const SLLEN: usize> Default for FlexTlsf<Source, FLBitmap, SLBitmap, FLLEN, SLLEN>
Initialization with a FlexSource
provided by Default::default