diff options
Diffstat (limited to 'src/memory')
-rw-r--r-- | src/memory/physalloc.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/memory/physalloc.c b/src/memory/physalloc.c index 5be7469..dccd980 100644 --- a/src/memory/physalloc.c +++ b/src/memory/physalloc.c @@ -26,6 +26,7 @@ static uint64_t total_memory; static uint64_t free_memory; static uint64_t page_count; static uint64_t page_free_start; +static uint64_t segment_count; static struct memory_area *page_start; static int n_pages(const struct memory_area *m) { @@ -34,7 +35,8 @@ static int n_pages(const struct memory_area *m) { static void *page_at(int i) { int cur_page = 0; - for (struct memory_area *m = page_start; m != NULL; m++) { + for (uint64_t idx = 0; idx < segment_count; idx++) { + struct memory_area *m = &page_start[idx]; int pages = n_pages(m); if (i - cur_page < pages) { return (void *) (m->addr + (PAGE_SIZE * (i - cur_page))); @@ -165,7 +167,7 @@ void memory_init(struct memory_map *map) { end += map->size; struct memory_segment *segment = &map->entries[0]; - int segment_count = 0; + segment_count = 0; for(; (uintptr_t) segment < end; segment++) { if (segment_invalid(segment)) |