mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-25 01:01:34 +11:00
Have a new() method
This commit is contained in:
parent
2bacbf35dc
commit
22c6efa5fa
|
@ -16,6 +16,14 @@ struct BumpAllocator {
|
||||||
current_ptr: Mutex<*mut u8>,
|
current_ptr: Mutex<*mut u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl BumpAllocator {
|
||||||
|
pub const fn new() -> Self {
|
||||||
|
Self {
|
||||||
|
current_ptr: Mutex::new(core::ptr::null_mut())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl BumpAllocator {
|
impl BumpAllocator {
|
||||||
fn alloc_safe(&self, layout: Layout) -> *mut u8 {
|
fn alloc_safe(&self, layout: Layout) -> *mut u8 {
|
||||||
let mut current_ptr = self.current_ptr.lock();
|
let mut current_ptr = self.current_ptr.lock();
|
||||||
|
@ -56,9 +64,7 @@ fn alloc_error(layout: Layout) -> ! {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[global_allocator]
|
#[global_allocator]
|
||||||
static GLOBAL_ALLOC: BumpAllocator = BumpAllocator {
|
static GLOBAL_ALLOC: BumpAllocator = BumpAllocator::new();
|
||||||
current_ptr: Mutex::new(core::ptr::null_mut()),
|
|
||||||
};
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
|
|
Loading…
Reference in a new issue