diff options
author | Anton Kling <anton@kling.gg> | 2024-04-15 23:47:25 +0200 |
---|---|---|
committer | Anton Kling <anton@kling.gg> | 2024-04-16 00:02:23 +0200 |
commit | efe10908766d96974c008a6a8f124916fdca7a14 (patch) | |
tree | 69f90dc3c01d32d63a38ab50f61268b1ac06dc97 /kernel/kmalloc.c | |
parent | 62ba2a9ab01e5f2a9b1cd325af8d3112702b7713 (diff) |
Kernel: Improve "out of memory" error handling
It can now boot with fairly low memory while not crashing and instead
gracefully failing the operation. Userland still does not properly
handle errors.
Diffstat (limited to 'kernel/kmalloc.c')
-rw-r--r-- | kernel/kmalloc.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/kernel/kmalloc.c b/kernel/kmalloc.c index 84a16bd..124e5a5 100644 --- a/kernel/kmalloc.c +++ b/kernel/kmalloc.c @@ -59,7 +59,7 @@ int init_heap(void) { } int add_heap_memory(size_t min_desired) { - min_desired += sizeof(MallocHeader) + 0x2000; + min_desired += sizeof(MallocHeader); size_t allocation_size = max(min_desired, NEW_ALLOC_SIZE); allocation_size += delta_page(allocation_size); void *p; @@ -157,7 +157,6 @@ void *int_kmalloc(size_t s) { if (!free_entry) { if (!add_heap_memory(s)) { klog("Ran out of memory.", LOG_ERROR); - assert(0); return NULL; } return kmalloc(s); |