diff options
author | Ian McFarlane <i.mcfarlane2002@gmail.com> | 2025-04-24 14:37:50 -0400 |
---|---|---|
committer | Ian McFarlane <i.mcfarlane2002@gmail.com> | 2025-04-24 14:37:50 -0400 |
commit | d113de791c51f8ea3a066569783783290451ad75 (patch) | |
tree | 9a45332375fc30074b1cfef2b4b2892c6f6a2d8f | |
parent | user.c for loading userspace elfs into memory (diff) | |
download | comus-d113de791c51f8ea3a066569783783290451ad75.tar.gz comus-d113de791c51f8ea3a066569783783290451ad75.tar.bz2 comus-d113de791c51f8ea3a066569783783290451ad75.zip |
size_t for alloc pages cals
-rw-r--r-- | kernel/memory/physalloc.c | 10 | ||||
-rw-r--r-- | kernel/memory/physalloc.h | 4 |
2 files changed, 7 insertions, 7 deletions
diff --git a/kernel/memory/physalloc.c b/kernel/memory/physalloc.c index b164358..60e7017 100644 --- a/kernel/memory/physalloc.c +++ b/kernel/memory/physalloc.c @@ -79,12 +79,12 @@ void *alloc_phys_page(void) return alloc_phys_pages(1); } -void *alloc_phys_pages(int pages) +void *alloc_phys_pages(size_t pages) { if (pages < 1) return NULL; - int n_contiguous = 0; + size_t n_contiguous = 0; int free_region_start = 0; for (uint64_t i = 0; i < page_count; i++) { bool free = !bitmap_get(i); @@ -94,7 +94,7 @@ void *alloc_phys_pages(int pages) free_region_start = i; n_contiguous++; if (n_contiguous == pages) { - for (int j = 0; j < pages; j++) + for (size_t j = 0; j < pages; j++) bitmap_set(free_region_start + j, true); return page_at(free_region_start); } @@ -110,7 +110,7 @@ void free_phys_page(void *ptr) free_phys_pages(ptr, 1); } -void free_phys_pages(void *ptr, int pages) +void free_phys_pages(void *ptr, size_t pages) { if (ptr == NULL) return; @@ -119,7 +119,7 @@ void free_phys_pages(void *ptr, int pages) if (idx == -1) return; - for (int i = 0; i < pages; i++) + for (size_t i = 0; i < pages; i++) bitmap_set(idx + pages, false); } diff --git a/kernel/memory/physalloc.h b/kernel/memory/physalloc.h index 7afe998..d91c57a 100644 --- a/kernel/memory/physalloc.h +++ b/kernel/memory/physalloc.h @@ -26,7 +26,7 @@ void *alloc_phys_page(void); * Allocates count physical pages in memory * @returns the physical address of the first page */ -void *alloc_phys_pages(int count); +void *alloc_phys_pages(size_t count); /** * Frees a single physical page in memory @@ -39,6 +39,6 @@ void free_phys_page(void *ptr); * @param ptr - the physical address of the first page * @param count - the number of pages in the list */ -void free_phys_pages(void *ptr, int count); +void free_phys_pages(void *ptr, size_t count); #endif /* physalloc.h */ |