increasing_heap_allocator/
lib.rs1#![no_std]
2
3pub use allocator::HeapAllocator;
4
5mod allocator;
6
7const fn align_up(addr: usize, alignment: usize) -> usize {
9 (addr + alignment - 1) & !(alignment - 1)
10}
11
12const fn is_aligned(addr: usize, alignment: usize) -> bool {
13 (addr & (alignment - 1)) == 0
14}
15
16#[derive(Debug, Clone, Copy)]
17pub struct HeapStats {
18 pub allocated: usize,
19 pub free_size: usize,
20 pub heap_size: usize,
21}
22
23pub trait PageAllocatorProvider<const PAGE_SIZE: usize> {
24 fn allocate_pages(&mut self, pages: usize) -> Option<*mut u8>;
26 fn deallocate_pages(&mut self, pages: usize) -> bool;
29}