aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-11-22 07:06:42 -0800
committerChris Robinson <[email protected]>2018-11-22 07:06:42 -0800
commitba8c865513d33019962a02e00ab496365de17abf (patch)
tree3ee05abc7044873f316003514e0aa0213cc1a41c
parentab6db9a589ac5ad8daa498e9fedb4de66cbb1948 (diff)
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.
-rw-r--r--Alc/mastering.h4
-rw-r--r--common/almalloc.h4
2 files changed, 5 insertions, 3 deletions
diff --git a/Alc/mastering.h b/Alc/mastering.h
index a6cf58ed..14111130 100644
--- a/Alc/mastering.h
+++ b/Alc/mastering.h
@@ -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:
diff --git a/common/almalloc.h b/common/almalloc.h
index ccaa6a98..d9b285fe 100644
--- a/common/almalloc.h
+++ b/common/almalloc.h
@@ -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>