[−][src]Struct basic_allocator::blocklist::BlockList
A BlockList
is a linked list of "free" blocks in memory.
Each block should be considered "owned" by the BlockList when inserted, and do not hold any sort of payload. They may be split or merged internally.
In this module, thse memory blocks represent freed memory that has not been returned to the OS, and provide a "pool" of available memory for reuse by the allocator.
It maintains a few internal invariants:
- Each block should link to the next, with the last one linking to null.
- Each block should have a pointer < next.
- No two blocks should be precisely adjacent (those should be automatically merged on insertion).
Implementations
impl BlockList
[src]
pub const fn header_size() -> usize
[src]
pub fn iter(&self) -> BlockIter
[src]
pub fn apply<C, R, F: FnMut(&mut FreeBlock, C) -> ApplyState<C, R>>(
&mut self,
start: C,
pred: F
) -> ApplyState<C, R>
[src]
&mut self,
start: C,
pred: F
) -> ApplyState<C, R>
Iterate through the blocklist, and apply a function at each step. This allows mutating the list as it is traversed, and replaces IterMut, which cannot be used due to the links between blocks.
Note that any changes to any block's "next" will be followed at the next iteration.
pub fn stats(&self) -> (Validity, Stats)
[src]
Check current size of the list, and whether its valid.
pub fn pop_size(&mut self, size: usize) -> Option<Range<NonNull<u8>>>
[src]
Find and remove a chunk of size 'size' from the linked list
pub unsafe fn add_block(&mut self, ptr: NonNull<u8>, size: usize)
[src]
Add a block to the linked list. Takes ownership of ptr.
Safety
ptr
must point to valid, reachable memory of at least size
, and
ownership of that memory must be transferred to BlockList
when this
method is called.
pub fn len(&self) -> usize
[src]
pub fn is_empty(&self) -> bool
[src]
Trait Implementations
impl Default for BlockList
[src]
impl Display for BlockList
[src]
impl<'list> IntoIterator for &'list BlockList
[src]
Auto Trait Implementations
impl RefUnwindSafe for BlockList
impl Send for BlockList
impl !Sync for BlockList
impl Unpin for BlockList
impl UnwindSafe for BlockList
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,