summaryrefslogtreecommitdiff
path: root/src/kernel/malloc.c
diff options
context:
space:
mode:
authordzwdz2024-07-13 23:37:37 +0200
committerdzwdz2024-07-13 23:37:37 +0200
commitc1d3ac750b8483c9a942d2fb5d5b7245d014e905 (patch)
tree630fb27832e15f3dfde0b0723c5e08a4421e8d22 /src/kernel/malloc.c
parentded843efbdad1ed048fe42c50c8fb68d50bafa51 (diff)
kernel/malloc: limit the maximum allocation size to under a page
This will likely be changed back, but for the time being it will let me implement a better allocator without too much effort.
Diffstat (limited to 'src/kernel/malloc.c')
-rw-r--r--src/kernel/malloc.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/kernel/malloc.c b/src/kernel/malloc.c
index 8ba00dc..ba1ab42 100644
--- a/src/kernel/malloc.c
+++ b/src/kernel/malloc.c
@@ -116,6 +116,7 @@ mem_debugprint(void)
void
*page_alloc(size_t pages)
{
+ assert(pages == 1); /* not using that assertion... yet */
/* i do realize how painfully slow this is */
size_t streak = 0;
for (size_t i = pbitmap_firstfree; i < pbitmap_len * 8; i++) {
@@ -177,7 +178,11 @@ void
Allocation *hdr;
void *addr;
+ if (KMALLOC_MAX < len) {
+ panic_invalid_state();
+ }
len += sizeof(Allocation);
+ assert(len <= PAGE_SIZE);
hdr = page_alloc(page_amt(len));
hdr->magic = MALLOC_MAGIC;
hdr->len = len;