mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-25 01:01: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>,
|
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 impl GlobalAlloc for BlockAllocator {
|
||||||
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
|
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
|
||||||
let block_layout = Layout::new::<Block>();
|
let block_layout = Layout::new::<Block>();
|
||||||
|
|
|
@ -3,12 +3,12 @@ use core::alloc::Layout;
|
||||||
mod block_allocator;
|
mod block_allocator;
|
||||||
mod bump_allocator;
|
mod bump_allocator;
|
||||||
|
|
||||||
use bump_allocator::BumpAllocator;
|
use block_allocator::BlockAllocator;
|
||||||
|
|
||||||
const EWRAM_END: usize = 0x0204_0000;
|
const EWRAM_END: usize = 0x0204_0000;
|
||||||
|
|
||||||
#[global_allocator]
|
#[global_allocator]
|
||||||
static GLOBAL_ALLOC: BumpAllocator = BumpAllocator::new();
|
static GLOBAL_ALLOC: BlockAllocator = unsafe { BlockAllocator::new() };
|
||||||
|
|
||||||
#[alloc_error_handler]
|
#[alloc_error_handler]
|
||||||
fn alloc_error(layout: Layout) -> ! {
|
fn alloc_error(layout: Layout) -> ! {
|
||||||
|
|
Loading…
Reference in a new issue