Heap

Struct Heap 

Source
pub struct Heap<const ORDER: usize> {
    pub allocated: usize,
    pub freeList: [LinkedList; ORDER],
    pub total: usize,
    pub user: usize,
}

Fields§

§allocated: usize§freeList: [LinkedList; ORDER]§total: usize§user: usize

Implementations§

Source§

impl<const ORDER: usize> Heap<ORDER>

Source

pub const fn new() -> Self

Create an empty heap.

Source

pub unsafe fn add_to_heap(&mut self, start: usize, end: usize)

Source

pub unsafe fn allocate( &mut self, layout: Layout, ) -> Result<NonNull<u8>, AllocationError>

Allocate a block of memory large enough to contain size bytes, and aligned on align. This will return NULL if the align is greater than MIN_HEAP_ALIGN, if align is not a power of 2, or if we can’t find enough memory.

All allocated memory must be passed to deallocate with the same size and align parameter, or else horrible things will happen.

Source

pub unsafe fn deallocate(&mut self, ptr: NonNull<u8>, layout: Layout)

Trait Implementations§

Source§

impl<const ORDER: usize> Debug for Heap<ORDER>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<const ORDER: usize> Freeze for Heap<ORDER>

§

impl<const ORDER: usize> RefUnwindSafe for Heap<ORDER>

§

impl<const ORDER: usize> Send for Heap<ORDER>

§

impl<const ORDER: usize> !Sync for Heap<ORDER>

§

impl<const ORDER: usize> Unpin for Heap<ORDER>

§

impl<const ORDER: usize> UnwindSafe for Heap<ORDER>

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.