mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 00:50:22 +00:00
e904f193c1
With a bunch of LibC work to support the feature. LibC now initializes AK::StringImpl by default. It's now fine to use AK in LibC/Userland! :^)
68 lines
1 KiB
C
68 lines
1 KiB
C
#pragma once
|
|
|
|
#include "Compiler.h"
|
|
|
|
#ifdef SERENITY
|
|
#ifdef KERNEL
|
|
#include <Kernel/kmalloc.h>
|
|
#else
|
|
#include <LibC/stdlib.h>
|
|
|
|
extern "C" {
|
|
|
|
void* kcalloc(size_t nmemb, size_t size);
|
|
void* kmalloc(size_t size) MALLOC_ATTR;
|
|
void kfree(void* ptr);
|
|
void* krealloc(void* ptr, size_t size);
|
|
|
|
}
|
|
|
|
inline void* operator new(size_t size)
|
|
{
|
|
return kmalloc(size);
|
|
}
|
|
|
|
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)
|
|
{
|
|
return kfree(ptr);
|
|
}
|
|
|
|
inline void operator delete(void* ptr, size_t)
|
|
{
|
|
return kfree(ptr);
|
|
}
|
|
|
|
inline void operator delete[](void* ptr, size_t)
|
|
{
|
|
return kfree(ptr);
|
|
}
|
|
|
|
inline void* operator new(size_t, void* p) { return p; }
|
|
inline void* operator new[](size_t, void* p) { return p; }
|
|
#endif
|
|
#else
|
|
#include <new>
|
|
|
|
#include "Types.h"
|
|
|
|
extern "C" {
|
|
|
|
void* kcalloc(size_t nmemb, size_t size);
|
|
void* kmalloc(size_t size) MALLOC_ATTR;
|
|
void kfree(void* ptr);
|
|
void* krealloc(void* ptr, size_t size);
|
|
|
|
}
|
|
|
|
#endif
|
|
|