aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/almalloc.h7
-rw-r--r--core/hrtf.cpp5
-rw-r--r--core/hrtf.h11
3 files changed, 12 insertions, 11 deletions
diff --git a/common/almalloc.h b/common/almalloc.h
index b64b6b20..82f050e4 100644
--- a/common/almalloc.h
+++ b/common/almalloc.h
@@ -30,13 +30,6 @@ gsl::owner<void*> al_calloc(size_t alignment, size_t size);
void operator delete(void*) noexcept = delete; \
void operator delete[](void*) noexcept = delete;
-#define DEF_PLACE_NEWDEL \
- void *operator new(size_t) = delete; \
- void *operator new[](size_t) = delete; \
- void operator delete(gsl::owner<void*> block, void*) noexcept { al_free(block); } \
- void operator delete(gsl::owner<void*> block) noexcept { al_free(block); } \
- void operator delete[](gsl::owner<void*> block, void*) noexcept { al_free(block); } \
- void operator delete[](gsl::owner<void*> block) noexcept { al_free(block); }
enum FamCount : size_t { };
diff --git a/core/hrtf.cpp b/core/hrtf.cpp
index 8fc4030e..d56c364e 100644
--- a/core/hrtf.cpp
+++ b/core/hrtf.cpp
@@ -392,10 +392,11 @@ std::unique_ptr<HrtfStore> CreateHrtfStore(uint rate, uint8_t irSize,
total += sizeof(std::declval<HrtfStore&>().mCoeffs[0])*irCount;
total += sizeof(std::declval<HrtfStore&>().mDelays[0])*irCount;
+ static constexpr auto AlignVal = std::align_val_t{alignof(HrtfStore)};
std::unique_ptr<HrtfStore> Hrtf{};
- if(void *ptr{al_calloc(16, total)})
+ if(gsl::owner<void*> ptr{::operator new[](total, AlignVal, std::nothrow)})
{
- Hrtf.reset(al::construct_at(static_cast<HrtfStore*>(ptr)));
+ Hrtf = decltype(Hrtf){::new(ptr) HrtfStore{}};
Hrtf->mRef.store(1u, std::memory_order_relaxed);
Hrtf->mSampleRate = rate & 0xff'ff'ff;
Hrtf->mIrSize = irSize;
diff --git a/core/hrtf.h b/core/hrtf.h
index 7a1a8b69..882724b8 100644
--- a/core/hrtf.h
+++ b/core/hrtf.h
@@ -18,7 +18,7 @@
#include "mixer/hrtfdefs.h"
-struct HrtfStore {
+struct alignas(16) HrtfStore {
std::atomic<uint> mRef;
uint mSampleRate : 24;
@@ -47,7 +47,14 @@ struct HrtfStore {
void add_ref();
void dec_ref();
- DEF_PLACE_NEWDEL
+ void *operator new(size_t) = delete;
+ void *operator new[](size_t) = delete;
+ void operator delete[](void*) noexcept = delete;
+
+ void operator delete(gsl::owner<void*> block, void*) noexcept
+ { ::operator delete[](block, std::align_val_t{alignof(HrtfStore)}); }
+ void operator delete(gsl::owner<void*> block) noexcept
+ { ::operator delete[](block, std::align_val_t{alignof(HrtfStore)}); }
};
using HrtfStorePtr = al::intrusive_ptr<HrtfStore>;