mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-24 08:41:34 +11:00
Use the block allocator by default now
This commit is contained in:
parent
4b9e4ce42a
commit
d372ca74bf
|
@ -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>();
|
||||
|
|
|
@ -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) -> ! {
|
||||
|
|
Loading…
Reference in a new issue