diff --git a/src/allocator/fixed_size_block.rs b/src/allocator/fixed_size_block.rs index a4c517bb..c83a12cd 100644 --- a/src/allocator/fixed_size_block.rs +++ b/src/allocator/fixed_size_block.rs @@ -1,3 +1,6 @@ +use alloc::alloc::Layout; +use core::ptr; + /// The block sizes to use. /// /// The sizes must each be power of 2 because they are also used as @@ -30,4 +33,12 @@ impl FixedSizeBlockAllocator { pub unsafe fn init(&mut self, heap_start: usize, heap_size: usize) { self.fallback_allocator.init(heap_start, heap_size); } + + /// Allocates using the fallback allocator. + fn fallback_alloc(&mut self, layout: Layout) -> *mut u8 { + match self.fallback_allocator.allocate_first_fit(layout) { + Ok(ptr) => ptr.as_ptr(), + Err(_) => ptr::null_mut(), + } + } }