diff --git a/agb/src/agb_alloc/block_allocator.rs b/agb/src/agb_alloc/block_allocator.rs index f1e1907..6dfb154 100644 --- a/agb/src/agb_alloc/block_allocator.rs +++ b/agb/src/agb_alloc/block_allocator.rs @@ -1,3 +1,8 @@ +//! The block allocator works by maintaining a linked list of unused blocks and +//! requesting new blocks using a bump allocator. Freed blocks are inserted into +//! the linked list in order of pointer. Blocks are then merged after every +//! free. + use core::alloc::{GlobalAlloc, Layout}; use core::cell::RefCell; @@ -10,11 +15,6 @@ use bare_metal::{CriticalSection, Mutex}; use super::bump_allocator::BumpAllocator; use super::SendNonNull; -/// The block allocator works by maintaining a linked list of unused blocks and -/// requesting new blocks using a bump allocator. Freed blocks are inserted into -/// the linked list in order of pointer. Blocks are then merged after every -/// free. - struct Block { size: usize, next: Option>, @@ -58,7 +58,7 @@ impl BlockAllocator { } } - #[allow(dead_code)] + #[cfg(test)] pub unsafe fn number_of_blocks(&self) -> u32 { free(|key| { let mut state = self.state.borrow(*key).borrow_mut(); diff --git a/agb/src/agb_alloc/mod.rs b/agb/src/agb_alloc/mod.rs index a63c0cc..4084f3a 100644 --- a/agb/src/agb_alloc/mod.rs +++ b/agb/src/agb_alloc/mod.rs @@ -35,7 +35,7 @@ const EWRAM_END: usize = 0x0204_0000; #[global_allocator] static GLOBAL_ALLOC: BlockAllocator = unsafe { BlockAllocator::new() }; -#[allow(dead_code)] +#[cfg(test)] pub unsafe fn number_of_blocks() -> u32 { GLOBAL_ALLOC.number_of_blocks() }