From b0f3336533e104e3d0cf087858b616e3411f117a Mon Sep 17 00:00:00 2001 From: Mattes D Date: Mon, 19 Jun 2017 11:09:16 +0200 Subject: MSVC Debug builds: Added operator new redirection to provide more info. (#3781) --- src/AllocationPool.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/AllocationPool.h') diff --git a/src/AllocationPool.h b/src/AllocationPool.h index b8fae4a95..d1769dc03 100644 --- a/src/AllocationPool.h +++ b/src/AllocationPool.h @@ -81,7 +81,19 @@ public: void * space = malloc(sizeof(T)); if (space != nullptr) { + #if defined(_MSC_VER) && defined(_DEBUG) + // The debugging-new that is set up using macros in Globals.h doesn't support the placement-new syntax used here. + // Temporarily disable the macro + #pragma push_macro("new") + #undef new + #endif + return new(space) T; + + #if defined(_MSC_VER) && defined(_DEBUG) + // Re-enable the debugging-new macro + #pragma pop_macro("new") + #endif } else if (m_FreeList.size() == NumElementsInReserve) { @@ -95,7 +107,21 @@ public: } } // placement new, used to initalize the object + + #if defined(_MSC_VER) && defined(_DEBUG) + // The debugging-new that is set up using macros in Globals.h doesn't support the placement-new syntax used here. + // Temporarily disable the macro + #pragma push_macro("new") + #undef new + #endif + T * ret = new (m_FreeList.front()) T; + + #if defined(_MSC_VER) && defined(_DEBUG) + // Re-enable the debugging-new macro + #pragma pop_macro("new") + #endif + m_FreeList.pop_front(); return ret; } -- cgit v1.2.3