mirror of
https://github.com/italicsjenga/agb.git
synced 2025-01-27 09:36:39 +11:00
module level docs and test cfg
This commit is contained in:
parent
f7693f553c
commit
970b38e7da
2 changed files with 7 additions and 7 deletions
|
@ -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::alloc::{GlobalAlloc, Layout};
|
||||||
|
|
||||||
use core::cell::RefCell;
|
use core::cell::RefCell;
|
||||||
|
@ -10,11 +15,6 @@ use bare_metal::{CriticalSection, Mutex};
|
||||||
use super::bump_allocator::BumpAllocator;
|
use super::bump_allocator::BumpAllocator;
|
||||||
use super::SendNonNull;
|
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 {
|
struct Block {
|
||||||
size: usize,
|
size: usize,
|
||||||
next: Option<SendNonNull<Block>>,
|
next: Option<SendNonNull<Block>>,
|
||||||
|
@ -58,7 +58,7 @@ impl BlockAllocator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[cfg(test)]
|
||||||
pub unsafe fn number_of_blocks(&self) -> u32 {
|
pub unsafe fn number_of_blocks(&self) -> u32 {
|
||||||
free(|key| {
|
free(|key| {
|
||||||
let mut state = self.state.borrow(*key).borrow_mut();
|
let mut state = self.state.borrow(*key).borrow_mut();
|
||||||
|
|
|
@ -35,7 +35,7 @@ const EWRAM_END: usize = 0x0204_0000;
|
||||||
#[global_allocator]
|
#[global_allocator]
|
||||||
static GLOBAL_ALLOC: BlockAllocator = unsafe { BlockAllocator::new() };
|
static GLOBAL_ALLOC: BlockAllocator = unsafe { BlockAllocator::new() };
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[cfg(test)]
|
||||||
pub unsafe fn number_of_blocks() -> u32 {
|
pub unsafe fn number_of_blocks() -> u32 {
|
||||||
GLOBAL_ALLOC.number_of_blocks()
|
GLOBAL_ALLOC.number_of_blocks()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue