Add kernel-side new and delete

This commit is contained in:
apio 2022-12-04 12:52:49 +01:00
parent b8239698db
commit adb2c2ab41
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -364,4 +364,34 @@ void dump_heap_usage()
kdbgln("-- Total memory allocated for heap: %zu bytes", alloc_total);
kdbgln("-- Heap memory in use by the kernel: %zu bytes", alloc_used);
}
void* operator new(usize size)
{
return kmalloc(size).expect_release_value("FIXME: Kernel new panics on OOM, since there are no exceptions");
}
void* operator new[](usize size)
{
return kmalloc(size).expect_release_value("FIXME: Kernel new[] panics on OOM, since there are no exceptions");
}
void operator delete(void* p)
{
kfree(p);
}
void operator delete[](void* p)
{
kfree(p);
}
void operator delete(void* p, usize)
{
kfree(p);
}
void operator delete[](void* p, usize)
{
kfree(p);
}