module level docs and test cfg

This commit is contained in:
Corwin Kuiper 2022-01-20 22:28:52 +00:00
parent f7693f553c
commit 970b38e7da
2 changed files with 7 additions and 7 deletions

View file

@ -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<SendNonNull<Block>>,
@ -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();

View file

@ -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()
}