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:
Andrew Kaster 2020-05-15 21:30:37 -06:00 committed by Andreas Kling
parent 0a2cab0928
commit 2c82347393
Notes: sideshowbarker 2024-07-19 06:20:43 +09:00
2 changed files with 30 additions and 30 deletions

View file

@ -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;

View file

@ -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);
}