summaryrefslogtreecommitdiff
path: root/AK
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-08-04 21:15:45 +0200
committerAndreas Kling <kling@serenityos.org>2020-08-04 21:16:07 +0200
commit000ef0ec3d0025753a545f14705e0046f92f4875 (patch)
tree7d9d9a725623df69d1f297fb41c37c174625a3b6 /AK
parent90dcab381add4cbe7424cd8564d405bf640240cc (diff)
downloadserenity-000ef0ec3d0025753a545f14705e0046f92f4875.zip
Revert "AK: Let the compiler provide the default new and delete operators"
This reverts commit 45b05e9734962b07f95630e76b9a680e1775f002. I forgot about the Toolchain build again. :^(
Diffstat (limited to 'AK')
-rw-r--r--AK/kmalloc.h47
1 files changed, 46 insertions, 1 deletions
diff --git a/AK/kmalloc.h b/AK/kmalloc.h
index c76678dc4f..6ef4caed0e 100644
--- a/AK/kmalloc.h
+++ b/AK/kmalloc.h
@@ -26,7 +26,7 @@
#pragma once
-#if !defined(__serenity__) || !defined(KERNEL)
+#ifndef __serenity__
# include <new>
#endif
@@ -44,8 +44,53 @@
# include <Kernel/Heap/kmalloc.h>
#else
# include <stdlib.h>
+
# define kcalloc calloc
# define kmalloc malloc
# define kfree free
# define krealloc realloc
+
+# ifdef __serenity__
+
+inline void* operator new(size_t size)
+{
+ return kmalloc(size);
+}
+
+inline void operator delete(void* ptr)
+{
+ return kfree(ptr);
+}
+
+inline void operator delete(void* ptr, size_t)
+{
+ return kfree(ptr);
+}
+
+inline void* operator new[](size_t size)
+{
+ return kmalloc(size);
+}
+
+inline void operator delete[](void* ptr)
+{
+ return kfree(ptr);
+}
+
+inline void operator delete[](void* ptr, size_t)
+{
+ return kfree(ptr);
+}
+
+inline void* operator new(size_t, void* ptr)
+{
+ return ptr;
+}
+
+inline void* operator new[](size_t, void* ptr)
+{
+ return ptr;
+}
+# endif
+
#endif