diff options
author | Andreas Kling <awesomekling@gmail.com> | 2018-10-10 11:53:07 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2018-10-10 11:53:07 +0200 |
commit | 5a300551574451fbf509685d11095bda4fcb20be (patch) | |
tree | 7bd68b5b0bc9daab6899be52dc694b7162dc6b89 /AK/kmalloc.cpp | |
download | serenity-5a300551574451fbf509685d11095bda4fcb20be.zip |
Import all this stuff into a single repo called Serenity.
Diffstat (limited to 'AK/kmalloc.cpp')
-rw-r--r-- | AK/kmalloc.cpp | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/AK/kmalloc.cpp b/AK/kmalloc.cpp new file mode 100644 index 0000000000..c9fe5a046e --- /dev/null +++ b/AK/kmalloc.cpp @@ -0,0 +1,66 @@ +#include <cstdio> +#include "SimpleMalloc.h" +#include <new> + +extern "C" { + +void* kcalloc(dword nmemb, dword size) +{ + if (!nmemb || !size) + return nullptr; + return SimpleMalloc::allocateZeroed(nmemb * size); +} + +void* kmalloc(dword size) +{ + if (!size) + return nullptr; + return SimpleMalloc::allocate(size); +} + +void kfree(void* ptr) +{ + if (!ptr) + return; + SimpleMalloc::free((byte*)ptr); +} + +void* krealloc(void* ptr, dword size) +{ + if (!ptr) + return ptr; + return SimpleMalloc::reallocate((byte*)ptr, size); +} + +} + +void* operator new(std::size_t size) +{ + return kmalloc(size); +} + +void* operator new[](std::size_t size) +{ + return kmalloc(size); +} + +void operator delete(void* ptr) +{ + return kfree(ptr); +} + +void operator delete[](void* ptr) +{ + return kfree(ptr); +} + +void operator delete(void* ptr, size_t) +{ + return kfree(ptr); +} + +void operator delete[](void* ptr, size_t) +{ + return kfree(ptr); +} + |