Block

Struct Block 

Source
#[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: u32

Stores magic number to check if block is allocated.

§hole_count: u8§heap: *mut Heap

Implementations§

Source§

impl Block

Source

pub fn set_allocated(&mut self)

Source

pub fn offset(&self, offset: usize) -> *mut u8

Source

pub fn object_to_line_num(object: *const u8) -> usize

Convert an address on this block into a line number.

Source

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

Source

pub fn new(at: *mut u8) -> &'static mut Self

Source

pub fn begin(&self) -> *mut u8

Source

pub fn end(&self) -> *mut u8

Source

pub fn is_in_block(&self, p: *const u8) -> bool

Source

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.

Source

pub fn line(&self, index: usize) -> *mut u8

Source

pub fn sweep<const MAJOR: bool>( &mut self, bitmap: &SpaceBitmap<8>, live: &SpaceBitmap<8>, line: &SpaceBitmap<LINE_SIZE>, ) -> SweepResult

Source

pub fn count_holes(&mut self, bitmap: &SpaceBitmap<LINE_SIZE>) -> usize

Source

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.

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.