From efe10908766d96974c008a6a8f124916fdca7a14 Mon Sep 17 00:00:00 2001 From: Anton Kling Date: Mon, 15 Apr 2024 23:47:25 +0200 Subject: 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. --- kernel/kmalloc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'kernel/kmalloc.c') 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); -- cgit v1.2.3