From 000ef0ec3d0025753a545f14705e0046f92f4875 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 4 Aug 2020 21:15:45 +0200 Subject: [PATCH] Revert "AK: Let the compiler provide the default new and delete operators" This reverts commit 45b05e9734962b07f95630e76b9a680e1775f002. I forgot about the Toolchain build again. :^( --- AK/kmalloc.h | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/AK/kmalloc.h b/AK/kmalloc.h index c76678dc4f4..6ef4caed0eb 100644 --- a/AK/kmalloc.h +++ b/AK/kmalloc.h @@ -26,7 +26,7 @@ #pragma once -#if !defined(__serenity__) || !defined(KERNEL) +#ifndef __serenity__ # include #endif @@ -44,8 +44,53 @@ # include #else # include + # 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