add custom alloc; still doesn't work

This commit is contained in:
mtgmonkey
2025-05-13 21:38:37 -04:00
parent b2475a7b27
commit 8901f41a01
4 changed files with 14 additions and 6 deletions

View File

@@ -63,9 +63,14 @@ impl AreaFrameAllocator {
}
}
fn find_frame(&mut self, size: usize, align: usize) -> Option<(Frame, usize)> {
fn add_frame(&mut self) {
self.next_free_frame.number += 1;
}
fn find_frame(&mut self, size: usize, _align: usize) -> Option<(Frame, usize)> {
let next_addr = self.next_free_frame.number * PAGE_SIZE + HEAP_START;
if &next_addr + core::mem::align_of::<Frame>() <= PAGE_SIZE + HEAP_START {
if &next_addr + core::mem::align_of::<Frame>() <= PAGE_SIZE + HEAP_START
&& size < core::mem::align_of::<Frame>()
{
Some((Frame::containing_address(next_addr), next_addr))
} else {
None
@@ -91,5 +96,5 @@ unsafe impl GlobalAlloc for Locked<AreaFrameAllocator> {
None => ptr::null_mut(),
}
}
unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {}
unsafe fn dealloc(&self, _ptr: *mut u8, _layout: Layout) {}
}