From 844f3b29d39c3fadcf4e89dd3accf8be00b25de5 Mon Sep 17 00:00:00 2001 From: Corwin Date: Tue, 13 Feb 2024 18:43:37 +0000 Subject: [PATCH] Remove global alloc support from the bump allocator Signed-off-by: Corwin --- agb/src/agb_alloc/bump_allocator.rs | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/agb/src/agb_alloc/bump_allocator.rs b/agb/src/agb_alloc/bump_allocator.rs index 2c154d48..24a8a3de 100644 --- a/agb/src/agb_alloc/bump_allocator.rs +++ b/agb/src/agb_alloc/bump_allocator.rs @@ -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>, -} - 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> { - 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) {} -}