Skip to main content

BaseAllocator

Trait BaseAllocator 

Source
pub trait BaseAllocator {
    // Required methods
    fn init(&mut self, start: usize, size: usize);
    fn add_memory(&mut self, start: usize, size: usize) -> AllocResult;
}
Expand description

The base allocator trait inherited by other allocator traits.

Provides common initialization methods for all allocator types.

Required Methods§

Source

fn init(&mut self, start: usize, size: usize)

Initialize the allocator with a free memory region.

§Arguments
  • start - Starting address of the memory region
  • size - Size of the memory region in bytes
§Examples
let mut alloc = MyAllocator;
alloc.init(0x8000_0000, 16 * 1024 * 1024);
Source

fn add_memory(&mut self, start: usize, size: usize) -> AllocResult

Add a free memory region to the allocator.

§Arguments
  • start - Starting address of the memory region
  • size - Size of the memory region in bytes
§Returns

Returns Ok(()) on success, or an error if the region overlaps with existing memory.

Implementors§

Source§

impl<const PAGE_SIZE: usize> BaseAllocator for BuddyPageAllocator<PAGE_SIZE>

Source§

impl<const PAGE_SIZE: usize> BaseAllocator for GlobalAllocator<PAGE_SIZE>

Source§

impl<const PAGE_SIZE: usize> BaseAllocator for CompositePageAllocator<PAGE_SIZE>