mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 00:01:34 +11:00
Remove global alloc support from the bump allocator
Signed-off-by: Corwin <corwin@kuiper.dev>
This commit is contained in:
parent
5f0d86e2e3
commit
844f3b29d3
|
@ -1,10 +1,7 @@
|
|||
use core::alloc::{GlobalAlloc, Layout};
|
||||
use core::cell::RefCell;
|
||||
use core::alloc::Layout;
|
||||
use core::ptr::NonNull;
|
||||
|
||||
use super::SendNonNull;
|
||||
use crate::interrupt::free;
|
||||
use bare_metal::Mutex;
|
||||
|
||||
pub(crate) struct StartEnd {
|
||||
pub start: fn() -> usize,
|
||||
|
@ -16,10 +13,6 @@ pub(crate) struct BumpAllocatorInner {
|
|||
start_end: StartEnd,
|
||||
}
|
||||
|
||||
pub(crate) struct BumpAllocator {
|
||||
inner: Mutex<RefCell<BumpAllocatorInner>>,
|
||||
}
|
||||
|
||||
impl BumpAllocatorInner {
|
||||
pub const fn new(start_end: StartEnd) -> Self {
|
||||
Self {
|
||||
|
@ -58,20 +51,3 @@ impl BumpAllocatorInner {
|
|||
NonNull::new(resulting_ptr as *mut _)
|
||||
}
|
||||
}
|
||||
|
||||
impl BumpAllocator {
|
||||
fn alloc_safe(&self, layout: Layout) -> Option<NonNull<u8>> {
|
||||
free(|key| self.inner.borrow(key).borrow_mut().alloc(layout))
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl GlobalAlloc for BumpAllocator {
|
||||
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
|
||||
match self.alloc_safe(layout) {
|
||||
None => core::ptr::null_mut(),
|
||||
Some(p) => p.as_ptr(),
|
||||
}
|
||||
}
|
||||
|
||||
unsafe fn dealloc(&self, _ptr: *mut u8, _layout: Layout) {}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue