This commit is contained in:
Jack Halford 2018-02-05 20:15:08 +01:00
parent 25a76fce29
commit 1bfdff2a76
2 changed files with 2 additions and 1 deletions

View file

@ -34,6 +34,8 @@ impl AreaFrameAllocator {
fn choose_next_area(&mut self) {
self.current_area = self.areas.clone().filter(|area| {
// filter in areas with remaining free frames
// i.e. next_free_frame is before the last frame
let address = area.base_addr + area.length - 1;
Frame::containing_address(address as usize) >= self.next_free_frame
}).min_by_key(|area| area.base_addr);

View file

@ -11,7 +11,6 @@ pub struct Frame {
pub const PAGE_SIZE: usize = 4096;
impl Frame {
fn containing_address(address: usize) -> Frame {
Frame{ number: address / PAGE_SIZE }