aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2020-03-23 16:00:50 -0700
committerChris Robinson <[email protected]>2020-03-23 16:00:50 -0700
commit6a3b3b180b7138e1ea1c9a2e345747e69d664411 (patch)
tree63facb74da575ac03a828d8f56f03cb5513d34f2
parentb53294e291c0e00b94639527ae84d03037029f1a (diff)
Add a macro to disable class-specific new/delete
-rw-r--r--al/auxeffectslot.h1
-rw-r--r--al/buffer.h2
-rw-r--r--al/effect.h2
-rw-r--r--al/filter.h4
-rw-r--r--al/listener.h2
-rw-r--r--al/source.h2
-rw-r--r--common/almalloc.h6
7 files changed, 19 insertions, 0 deletions
diff --git a/al/auxeffectslot.h b/al/auxeffectslot.h
index 2471447f..327cb357 100644
--- a/al/auxeffectslot.h
+++ b/al/auxeffectslot.h
@@ -92,6 +92,7 @@ struct ALeffectslot {
static ALeffectslotArray *CreatePtrArray(size_t count) noexcept;
+ /* This can be new'd for the context's default effect slot. */
DEF_NEWDEL(ALeffectslot)
};
diff --git a/al/buffer.h b/al/buffer.h
index 61ae1863..15546ac9 100644
--- a/al/buffer.h
+++ b/al/buffer.h
@@ -104,6 +104,8 @@ struct ALbuffer {
inline ALuint bytesFromFmt() const noexcept { return BytesFromFmt(mFmtType); }
inline ALuint channelsFromFmt() const noexcept { return ChannelsFromFmt(mFmtChannels); }
inline ALuint frameSizeFromFmt() const noexcept { return channelsFromFmt() * bytesFromFmt(); }
+
+ DISABLE_ALLOC()
};
#endif
diff --git a/al/effect.h b/al/effect.h
index 270b8e20..25225396 100644
--- a/al/effect.h
+++ b/al/effect.h
@@ -47,6 +47,8 @@ struct ALeffect {
/* Self ID */
ALuint id{0u};
+
+ DISABLE_ALLOC()
};
inline ALboolean IsReverbEffect(ALenum type)
diff --git a/al/filter.h b/al/filter.h
index db098d70..48906dd9 100644
--- a/al/filter.h
+++ b/al/filter.h
@@ -4,6 +4,8 @@
#include "AL/al.h"
#include "AL/alc.h"
+#include "almalloc.h"
+
#define LOWPASSFREQREF (5000.0f)
#define HIGHPASSFREQREF (250.0f)
@@ -43,6 +45,8 @@ struct ALfilter {
/* Self ID */
ALuint id;
+
+ DISABLE_ALLOC()
};
#define ALfilter_setParami(o, c, p, v) ((o)->vtab->setParami(o, c, p, v))
#define ALfilter_setParamf(o, c, p, v) ((o)->vtab->setParamf(o, c, p, v))
diff --git a/al/listener.h b/al/listener.h
index 318ab024..69276f1a 100644
--- a/al/listener.h
+++ b/al/listener.h
@@ -57,6 +57,8 @@ struct ALlistener {
} Params;
ALlistener() { PropsClean.test_and_set(std::memory_order_relaxed); }
+
+ DISABLE_ALLOC()
};
void UpdateListenerProps(ALCcontext *context);
diff --git a/al/source.h b/al/source.h
index a800f299..a36a2a09 100644
--- a/al/source.h
+++ b/al/source.h
@@ -124,6 +124,8 @@ struct ALsource {
ALsource(const ALsource&) = delete;
ALsource& operator=(const ALsource&) = delete;
+
+ DISABLE_ALLOC()
};
void UpdateAllSourceProps(ALCcontext *context);
diff --git a/common/almalloc.h b/common/almalloc.h
index d56c8543..fc83b0d8 100644
--- a/common/almalloc.h
+++ b/common/almalloc.h
@@ -18,6 +18,12 @@ void *al_calloc(size_t alignment, size_t size);
void al_free(void *ptr) noexcept;
+#define DISABLE_ALLOC() \
+ void *operator new(size_t) = delete; \
+ void *operator new[](size_t) = delete; \
+ void operator delete(void*) noexcept = delete; \
+ void operator delete[](void*) noexcept = delete;
+
#define DEF_NEWDEL(T) \
void *operator new(size_t size) \
{ \