add custom alloc; still doesn't work
This commit is contained in:
@@ -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) {}
|
||||
}
|
||||
|
Reference in New Issue
Block a user