BAN: implement placement new

This commit is contained in:
Bananymous 2023-01-13 13:49:34 +02:00
parent 61de71e0d5
commit 82a25f9035
3 changed files with 14 additions and 14 deletions

View File

@ -1,13 +0,0 @@
#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); }

View File

@ -33,7 +33,6 @@ FREEOBJS= \
$(ARCH_FREEOBJS) \
BAN/String.o \
BAN/StringView.o \
BAN/Memory.o \
HOSTEDOBJS=\
$(ARCH_HOSTEDOBJS) \

View File

@ -37,3 +37,17 @@ namespace BAN
};
}
namespace std { enum class align_val_t : size_t {}; }
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 new(size_t size, std::align_val_t align) { return BAN::allocator_align(size, (size_t)align); }
inline void* operator new[](size_t size, std::align_val_t align) { return BAN::allocator_align(size, (size_t)align); }
inline void* operator new(size_t, void* addr) { return addr; }
inline void* operator new[](size_t, void* addr) { return addr; }
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); }