aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-01-11 20:06:23 -0800
committerChris Robinson <[email protected]>2019-01-11 20:06:23 -0800
commit77447fcd542d0e27b0e19caa666c0246c0cb05d2 (patch)
treea4ee0167c1bbd45209ee5fa5ecfa4ec7fec3a909
parent852c5005ab0b4709a6efa125146b01902950d273 (diff)
Add placement operator delete
-rw-r--r--OpenAL32/alAuxEffectSlot.cpp2
-rw-r--r--common/almalloc.h10
2 files changed, 8 insertions, 4 deletions
diff --git a/OpenAL32/alAuxEffectSlot.cpp b/OpenAL32/alAuxEffectSlot.cpp
index 47fff9d1..c9803819 100644
--- a/OpenAL32/alAuxEffectSlot.cpp
+++ b/OpenAL32/alAuxEffectSlot.cpp
@@ -190,7 +190,7 @@ ALeffectslotArray *ALeffectslot::CreatePtrArray(size_t count) noexcept
/* Allocate space for twice as many pointers, so the mixer has scratch
* space to store a sorted list during mixing.
*/
- void *ptr{al_calloc(DEF_ALIGN, ALeffectslotArray::CalcSizeof(count*2))};
+ void *ptr{al_calloc(DEF_ALIGN, ALeffectslotArray::Sizeof(count*2))};
return new (ptr) ALeffectslotArray{count};
}
diff --git a/common/almalloc.h b/common/almalloc.h
index cc46f144..166ac8c9 100644
--- a/common/almalloc.h
+++ b/common/almalloc.h
@@ -34,7 +34,8 @@ int al_is_sane_alignment_allocator(void) noexcept;
#define DEF_PLACE_NEWDEL() \
void *operator new(size_t /*size*/, void *ptr) noexcept { return ptr; } \
- void operator delete(void *block) noexcept { al_free(block); }
+ void operator delete(void *block) noexcept { al_free(block); } \
+ void operator delete(void* /*block*/, void* /*ptr*/) noexcept { }
namespace al {
@@ -101,8 +102,11 @@ struct FlexArray {
const size_t mSize;
alignas(alignment) T mArray[];
- static constexpr size_t CalcSizeof(size_t count) noexcept
- { return std::max<size_t>(offsetof(FlexArray, mArray) + sizeof(T)*count, sizeof(FlexArray)); }
+ static constexpr size_t Sizeof(size_t count, size_t base=0u) noexcept
+ {
+ return base +
+ std::max<size_t>(offsetof(FlexArray, mArray) + sizeof(T)*count, sizeof(FlexArray));
+ }
FlexArray(size_t size) : mSize{size}
{ new (mArray) T[mSize]; }