Struct slabmalloc_safe::ObjectPage8k
source · #[repr(C)]pub struct ObjectPage8k { /* private fields */ }
Expand description
Holds allocated data within 2 4-KiB pages.
Has a data-section where objects are allocated from and a small amount of meta-data in the form of a bitmap to track allocations at the end of the page.
Notes
An object of this type will be exactly 8 KiB.
It is marked repr(C)
because we rely on a well defined order of struct
members (e.g., dealloc does a cast to find the bitfield).
Trait Implementations§
source§impl AllocablePage for ObjectPage8k
impl AllocablePage for ObjectPage8k
source§fn clear_metadata(&mut self)
fn clear_metadata(&mut self)
clears the metadata section of the page
source§fn first_fit(&self, layout: Layout) -> Option<(usize, usize)>
fn first_fit(&self, layout: Layout) -> Option<(usize, usize)>
Tries to find a free block within data
that satisfies alignment
requirement.
source§fn allocate(&mut self, layout: Layout) -> *mut u8
fn allocate(&mut self, layout: Layout) -> *mut u8
Tries to allocate an object within this page.
In case the slab is full, returns a null ptr.
source§fn is_full(&self) -> bool
fn is_full(&self) -> bool
Checks if we can still allocate more objects of a given layout within the page.
source§fn is_empty(&self, relevant_bits: usize) -> bool
fn is_empty(&self, relevant_bits: usize) -> bool
Checks if the page has currently no allocations.
source§fn deallocate(
&self,
ptr: NonNull<u8>,
layout: Layout
) -> Result<(), &'static str>
fn deallocate( &self, ptr: NonNull<u8>, layout: Layout ) -> Result<(), &'static str>
Deallocates a memory object within this page.
const METADATA_SIZE: usize = 80usize
const HEAP_ID_OFFSET: usize = 8_112usize
fn bitfield(&self) -> &[AtomicU64; 8]
fn bitfield_mut(&mut self) -> &mut [AtomicU64; 8]
Auto Trait Implementations§
impl RefUnwindSafe for ObjectPage8k
impl Send for ObjectPage8k
impl Sync for ObjectPage8k
impl Unpin for ObjectPage8k
impl UnwindSafe for ObjectPage8k
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more