From 57c5eceb846f3109d017b4e6d4cbd7c507c0d098 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Sat, 14 Mar 2015 16:16:53 +0100 Subject: Begin implement escape sequence handling in terminal. --- src/kernel/core/kmalloc.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/kernel/core/kmalloc.c') diff --git a/src/kernel/core/kmalloc.c b/src/kernel/core/kmalloc.c index 53ac83c..95347b3 100644 --- a/src/kernel/core/kmalloc.c +++ b/src/kernel/core/kmalloc.c @@ -10,7 +10,14 @@ void* page_alloc_fun_for_kmalloc(size_t bytes) { void* addr = region_alloc(bytes, "Core kernel heap"); - if (addr == 0) return 0; + if (addr == 0) { + if (SPAM_OOM_REASON) { + dbg_printf("Could not allocate region for kmalloc.\n"); + dbg_print_frame_stats(); + dbg_print_region_info(); + } + return 0; + } // Map physical memory for (void* i = addr; i < addr + bytes; i += PAGE_SIZE) { @@ -74,6 +81,7 @@ void* malloc(size_t sz) { int tries = 0; while ((res = malloc0(sz)) == 0 && (tries++) < 3) { + if (SPAM_OOM_REASON) dbg_printf("OOM in kmalloc\n"); free_some_memory(); } -- cgit v1.2.3