mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-24 00:31: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>,
|
||||
}
|
||||
|
||||
impl BumpAllocator {
|
||||
pub const fn new() -> Self {
|
||||
Self {
|
||||
current_ptr: Mutex::new(core::ptr::null_mut())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl BumpAllocator {
|
||||
fn alloc_safe(&self, layout: Layout) -> *mut u8 {
|
||||
let mut current_ptr = self.current_ptr.lock();
|
||||
|
@ -56,9 +64,7 @@ fn alloc_error(layout: Layout) -> ! {
|
|||
}
|
||||
|
||||
#[global_allocator]
|
||||
static GLOBAL_ALLOC: BumpAllocator = BumpAllocator {
|
||||
current_ptr: Mutex::new(core::ptr::null_mut()),
|
||||
};
|
||||
static GLOBAL_ALLOC: BumpAllocator = BumpAllocator::new();
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
|
|
Loading…
Reference in a new issue