#[repr(C, align(16))]pub struct Block {
pub all_next: *mut Self,
pub next: *mut Self,
pub allocated: u32,
pub hole_count: u8,
pub heap: *mut Heap,
}Expand description
A block is a page-aligned container for heap-allocated objects.
Fields§
§all_next: *mut Self§next: *mut Self§allocated: u32Stores magic number to check if block is allocated.
hole_count: u8§heap: *mut HeapImplementations§
Source§impl Block
impl Block
pub fn set_allocated(&mut self)
pub fn offset(&self, offset: usize) -> *mut u8
Sourcepub fn object_to_line_num(object: *const u8) -> usize
pub fn object_to_line_num(object: *const u8) -> usize
Convert an address on this block into a line number.
Sourcepub unsafe fn get_block_ptr(object: *const u8) -> *mut Self
pub unsafe fn get_block_ptr(object: *const u8) -> *mut Self
Get pointer to block from object pointer.
§Safety
Does not do anything unsafe but might return wrong pointer
pub fn new(at: *mut u8) -> &'static mut Self
pub fn begin(&self) -> *mut u8
pub fn end(&self) -> *mut u8
pub fn is_in_block(&self, p: *const u8) -> bool
Sourcepub fn update_lines<const MARK: bool>(
&self,
bitmap: &SpaceBitmap<LINE_SIZE>,
object: *const u8,
)
pub fn update_lines<const MARK: bool>( &self, bitmap: &SpaceBitmap<LINE_SIZE>, object: *const u8, )
Update the line counter for the given object.
Mark if MARK, otherwise clear mark bit.
pub fn line(&self, index: usize) -> *mut u8
pub fn sweep<const MAJOR: bool>( &mut self, bitmap: &SpaceBitmap<8>, live: &SpaceBitmap<8>, line: &SpaceBitmap<LINE_SIZE>, ) -> SweepResult
pub fn count_holes(&mut self, bitmap: &SpaceBitmap<LINE_SIZE>) -> usize
Sourcepub fn scan_block(
&self,
bitmap: &SpaceBitmap<LINE_SIZE>,
last_high_offset: u16,
) -> Option<(u16, u16)>
pub fn scan_block( &self, bitmap: &SpaceBitmap<LINE_SIZE>, last_high_offset: u16, ) -> Option<(u16, u16)>
Scan the block for a hole to allocate into.
The scan will start at last_high_offset bytes into the block and
return a tuple of low_offset, high_offset as the lowest and
highest usable offsets for a hole.
None is returned if no hole was found.
pub fn init(&mut self, heap: *mut Heap)
Auto Trait Implementations§
impl Freeze for Block
impl !RefUnwindSafe for Block
impl !Send for Block
impl !Sync for Block
impl Unpin for Block
impl !UnwindSafe for Block
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