Add kernel-side new and delete
This commit is contained in:
parent
b8239698db
commit
adb2c2ab41
@ -365,3 +365,33 @@ 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);
|
||||
}
|
Loading…
Reference in New Issue
Block a user