Use the block allocator by default now

This commit is contained in:
Gwilym Kuiper 2021-08-16 22:31:10 +01:00
parent 4b9e4ce42a
commit d372ca74bf
2 changed files with 14 additions and 2 deletions

View file

@ -29,6 +29,18 @@ pub(crate) struct BlockAllocator {
state: Mutex<BlockAllocatorState>,
}
impl BlockAllocator {
pub(super) const unsafe fn new() -> Self {
Self {
inner_allocator: BumpAllocator::new(),
state: Mutex::new(BlockAllocatorState {
first_block: None,
last_block: None,
}),
}
}
}
unsafe impl GlobalAlloc for BlockAllocator {
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
let block_layout = Layout::new::<Block>();

View file

@ -3,12 +3,12 @@ use core::alloc::Layout;
mod block_allocator;
mod bump_allocator;
use bump_allocator::BumpAllocator;
use block_allocator::BlockAllocator;
const EWRAM_END: usize = 0x0204_0000;
#[global_allocator]
static GLOBAL_ALLOC: BumpAllocator = BumpAllocator::new();
static GLOBAL_ALLOC: BlockAllocator = unsafe { BlockAllocator::new() };
#[alloc_error_handler]
fn alloc_error(layout: Layout) -> ! {