mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 09:51:57 -05:00
AK: Let the compiler provide the default new and delete operators
...except in kernelspace.
This commit is contained in:
parent
3cb8ae873c
commit
45b05e9734
1 changed files with 1 additions and 46 deletions
47
AK/kmalloc.h
47
AK/kmalloc.h
|
@ -26,7 +26,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#ifndef __serenity__
|
||||
#if !defined(__serenity__) || !defined(KERNEL)
|
||||
# include <new>
|
||||
#endif
|
||||
|
||||
|
@ -44,53 +44,8 @@
|
|||
# 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
|
||||
|
|
Loading…
Add table
Reference in a new issue