BAN: Move operator new/delete to BAN/Memory.cpp
We also now implement alignment new
This commit is contained in:
parent
64c57ea3d0
commit
d02e3b19c7
|
@ -0,0 +1,13 @@
|
|||
#include <BAN/Memory.h>
|
||||
|
||||
namespace std { enum class align_val_t : size_t {}; }
|
||||
|
||||
void* operator new(size_t size) { return BAN::allocator(size); }
|
||||
void* operator new[](size_t size) { return BAN::allocator(size); }
|
||||
void* operator new(size_t size, std::align_val_t al) { return BAN::allocator_align(size, (size_t)al); }
|
||||
void* operator new[](size_t size, std::align_val_t al) { return BAN::allocator_align(size, (size_t)al); }
|
||||
|
||||
void operator delete(void* addr) { BAN::deallocator(addr); }
|
||||
void operator delete[](void* addr) { BAN::deallocator(addr); }
|
||||
void operator delete(void* addr, size_t) { BAN::deallocator(addr); }
|
||||
void operator delete[](void* addr, size_t) { BAN::deallocator(addr); }
|
|
@ -33,6 +33,7 @@ FREEOBJS= \
|
|||
$(ARCH_FREEOBJS) \
|
||||
BAN/String.o \
|
||||
BAN/StringView.o \
|
||||
BAN/Memory.o \
|
||||
|
||||
HOSTEDOBJS=\
|
||||
$(ARCH_HOSTEDOBJS) \
|
||||
|
|
|
@ -10,6 +10,7 @@ namespace BAN
|
|||
{
|
||||
#if defined(__is_kernel)
|
||||
static constexpr void*(&allocator)(size_t) = kmalloc;
|
||||
static constexpr void*(&allocator_align)(size_t, size_t) = kmalloc;
|
||||
static constexpr void(&deallocator)(void*) = kfree;
|
||||
#else
|
||||
static constexpr void*(&allocator)(size_t) = malloc;
|
||||
|
@ -36,11 +37,3 @@ namespace BAN
|
|||
};
|
||||
|
||||
}
|
||||
|
||||
inline void* operator new(size_t size) { return BAN::allocator(size); }
|
||||
inline void* operator new[](size_t size) { return BAN::allocator(size); }
|
||||
|
||||
inline void operator delete(void* addr) { BAN::deallocator(addr); }
|
||||
inline void operator delete[](void* addr) { BAN::deallocator(addr); }
|
||||
inline void operator delete(void* addr, size_t) { BAN::deallocator(addr); }
|
||||
inline void operator delete[](void* addr, size_t) { BAN::deallocator(addr); }
|
Loading…
Reference in New Issue