mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 00:50:22 +00:00
AK+LibC: Move non-placement new/delete into LibC
This allows operator new and operator delete to be available to anyone that links -lc (everyone) rather than just people that include kmalloc.h (almost no one).
This commit is contained in:
parent
0a2cab0928
commit
2c82347393
Notes:
sideshowbarker
2024-07-19 06:20:43 +09:00
Author: https://github.com/ADKaster Commit: https://github.com/SerenityOS/serenity/commit/2c823473930 Pull-request: https://github.com/SerenityOS/serenity/pull/2242 Reviewed-by: https://github.com/bugaevc
2 changed files with 30 additions and 30 deletions
30
AK/kmalloc.h
30
AK/kmalloc.h
|
@ -52,36 +52,6 @@
|
|||
|
||||
# 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;
|
||||
|
|
|
@ -439,3 +439,33 @@ void __malloc_init()
|
|||
new (&big_allocators()[0])(BigAllocator);
|
||||
}
|
||||
}
|
||||
|
||||
void* operator new(size_t size)
|
||||
{
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
void* operator new[](size_t size)
|
||||
{
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
void operator delete(void* ptr)
|
||||
{
|
||||
return free(ptr);
|
||||
}
|
||||
|
||||
void operator delete(void* ptr, size_t)
|
||||
{
|
||||
return free(ptr);
|
||||
}
|
||||
|
||||
void operator delete[](void* ptr)
|
||||
{
|
||||
return free(ptr);
|
||||
}
|
||||
|
||||
void operator delete[](void* ptr, size_t)
|
||||
{
|
||||
return free(ptr);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue