use crate::marker::{MARKER_FREE, MARKER_USED};
#[repr(align(16))]
pub struct AllocationHeader {
marker: [u8; 8],
size: usize,
}
impl AllocationHeader {
#[inline]
pub const fn get_size(&self) -> usize {
self.size
}
#[inline]
pub fn is_marked_as_free(&self) -> bool {
self.marker == MARKER_FREE
}
#[inline]
pub fn is_marked_as_used(&self) -> bool {
self.marker == MARKER_USED
}
#[inline]
pub const fn mark_as_free(&mut self) {
self.marker = MARKER_FREE;
}
#[inline]
pub const fn mark_as_used(&mut self) {
self.marker = MARKER_USED;
}
#[inline]
pub const fn set_size(&mut self, new_size: usize) {
self.size = new_size;
}
}
pub const HEADER_SIZE: usize = std::mem::size_of::<AllocationHeader>();