mirror of
https://github.com/italicsjenga/agb.git
synced 2025-01-11 09:31:34 +11:00
module level docs and test cfg
This commit is contained in:
parent
f7693f553c
commit
970b38e7da
|
@ -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();
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue