Add and use a macro to define placement-new-only allocators
This is for structs that utilize over-allocation, either flexible array members, or which store optional additional objects in the same allocation block.
This commit is contained in:
+1
-3
@@ -61,9 +61,7 @@ struct Compressor {
|
||||
ALfloat LastAttack;
|
||||
ALfloat LastGainDev;
|
||||
|
||||
void *operator new(size_t size) = delete;
|
||||
void *operator new(size_t /*size*/, void *ptr) noexcept { return ptr; }
|
||||
void operator delete(void *block) noexcept { al_free(block); }
|
||||
DEF_PLACE_NEWDEL()
|
||||
};
|
||||
|
||||
/* The compressor is initialized with the following settings:
|
||||
|
||||
@@ -31,6 +31,10 @@ int al_is_sane_alignment_allocator(void) noexcept;
|
||||
} \
|
||||
void operator delete(void *block) noexcept { al_free(block); }
|
||||
|
||||
#define DEF_PLACE_NEWDEL() \
|
||||
void *operator new(size_t /*size*/, void *ptr) noexcept { return ptr; } \
|
||||
void operator delete(void *block) noexcept { al_free(block); }
|
||||
|
||||
namespace al {
|
||||
|
||||
template<typename T, size_t alignment=DEF_ALIGN>
|
||||
|
||||
Reference in New Issue
Block a user