diff --git a/src/memory/frame.c b/src/memory/frame.c index 1c0b4bf..ad256c2 100644 --- a/src/memory/frame.c +++ b/src/memory/frame.c @@ -14,7 +14,7 @@ static uint32_t remaining_frames = MAX_FRAMES; static int32_t find_next_block(size_t nb_frames) { - for (uint32_t i = 1; i < MAX_FRAMES; i++) { + for (uint32_t i = 1; i + nb_frames < MAX_FRAMES - 1; i++) { uint32_t j; for (j = 0; frame_table[i + j] == 0 && j < nb_frames; j++) ; diff --git a/src/memory/page.c b/src/memory/page.c index 947f894..4a78ee3 100644 --- a/src/memory/page.c +++ b/src/memory/page.c @@ -14,7 +14,7 @@ extern uint32_t page_table1[PT_SIZE]; static int16_t find_next_block(size_t nb_pages) { - for (uint16_t i = 1; i < PT_SIZE - 1; i++) { + for (uint16_t i = 1; i + nb_pages < PT_SIZE - 1; i++) { uint16_t j; for (j = 0; page_table1[i + j] >> 12 == i + j && j < nb_pages; j++)