aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/core/kmalloc.c
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2015-03-14 16:16:53 +0100
committerAlex Auvolat <alex@adnab.me>2015-03-14 16:16:53 +0100
commit57c5eceb846f3109d017b4e6d4cbd7c507c0d098 (patch)
treed4aa0917310a5ad7925736f9dadc07bcb5734383 /src/kernel/core/kmalloc.c
parentf574c22f86d90f735107fda199bb5b4982cd9621 (diff)
downloadkogata-57c5eceb846f3109d017b4e6d4cbd7c507c0d098.tar.gz
kogata-57c5eceb846f3109d017b4e6d4cbd7c507c0d098.zip
Begin implement escape sequence handling in terminal.
Diffstat (limited to 'src/kernel/core/kmalloc.c')
-rw-r--r--src/kernel/core/kmalloc.c10
1 files changed, 9 insertions, 1 deletions
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();
}