aboutsummaryrefslogtreecommitdiff
path: root/src/zencore/memory/memory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/zencore/memory/memory.cpp')
-rw-r--r--src/zencore/memory/memory.cpp38
1 files changed, 35 insertions, 3 deletions
diff --git a/src/zencore/memory/memory.cpp b/src/zencore/memory/memory.cpp
index fced2a4d3..fc8de5d02 100644
--- a/src/zencore/memory/memory.cpp
+++ b/src/zencore/memory/memory.cpp
@@ -39,19 +39,23 @@ InitGMalloc()
FMalloc* InitMalloc = GMalloc;
// Pick a default base allocator based on availability/platform
+ // when using sanitizers, we should use the default/ansi allocator
-#if ZEN_MIMALLOC_ENABLED
+#if ZEN_OVERRIDE_NEW_DELETE
+
+# if ZEN_MIMALLOC_ENABLED
if (Malloc == MallocImpl::None)
{
Malloc = MallocImpl::Mimalloc;
}
-#endif
+# endif
-#if ZEN_RPMALLOC_ENABLED
+# if ZEN_RPMALLOC_ENABLED
if (Malloc == MallocImpl::None)
{
Malloc = MallocImpl::Rpmalloc;
}
+# endif
#endif
// Process any command line overrides
@@ -287,6 +291,8 @@ zen_free_aligned(void* Ptr, size_t Alignment) noexcept
// EASTL operator new
+#if ZEN_OVERRIDE_NEW_DELETE
+
void*
operator new[](size_t size, const char* pName, int flags, unsigned debugFlags, const char* file, int line)
{
@@ -310,3 +316,29 @@ operator new[](size_t size,
return zen_new_aligned(size, alignment);
}
+
+#else
+
+void*
+operator new[](size_t size, const char* pName, int flags, unsigned debugFlags, const char* file, int line)
+{
+ ZEN_UNUSED(pName, flags, debugFlags, file, line);
+ return ::operator new[](size);
+}
+
+void*
+operator new[](size_t size,
+ size_t alignment,
+ size_t alignmentOffset,
+ const char* pName,
+ int flags,
+ unsigned debugFlags,
+ const char* file,
+ int line)
+{
+ ZEN_UNUSED(alignmentOffset, pName, flags, debugFlags, file, line);
+ ZEN_ASSERT_SLOW(alignmentOffset == 0); // currently not supported
+ return ::operator new[](size, std::align_val_t(alignment));
+}
+
+#endif