From a188500609e658fc0b1be7298b5d100574159627 Mon Sep 17 00:00:00 2001 From: Nicolas Hake Date: Thu, 21 Jul 2016 19:43:34 +0200 Subject: [PATCH] Remove MS CRT memory management debugging Redefining new breaks perfectly valid code, but only on MSVC and only in one particular configuration (Debug). This is very annoying because it means people not using MSVC, or even people doing Release builds, can write standards-conforming code which then may fail to build for other people. --- src/C4Include.h | 17 ----------------- src/landscape/C4Particles.h | 3 --- src/lib/C4Random.cpp | 3 --- src/lib/Standard.h | 3 --- 4 files changed, 26 deletions(-) diff --git a/src/C4Include.h b/src/C4Include.h index d7c799daf..a616b39d2 100644 --- a/src/C4Include.h +++ b/src/C4Include.h @@ -66,23 +66,6 @@ don't need to include this file or any of the files it includes. */ #include namespace re = std; -// debug memory management - must come after standard headers, -// because those libraries use placement new -#ifndef NODEBUGMEM -#if defined(_DEBUG) && defined(_MSC_VER) -#define _CRTDBG_MAP_ALLOC -#include -#include -inline void *operator new(size_t s, const char *szFile, long iLine) -{ return ::operator new(s, _NORMAL_BLOCK, szFile, iLine); } -inline void operator delete(void *p, const char *, long) -{ ::operator delete(p); } -#define new_orig new -#define new new(__FILE__, __LINE__) -#endif -#endif -#include - #include "lib/Standard.h" #include "C4Prototypes.h" #include "lib/C4Real.h" diff --git a/src/landscape/C4Particles.h b/src/landscape/C4Particles.h index c2efa7b4e..ddbc0aa74 100644 --- a/src/landscape/C4Particles.h +++ b/src/landscape/C4Particles.h @@ -18,10 +18,7 @@ #include "platform/StdScheduler.h" -#pragma push_macro("new") -#undef new #include -#pragma pop_macro("new") #ifndef INC_C4Particles #define INC_C4Particles diff --git a/src/lib/C4Random.cpp b/src/lib/C4Random.cpp index ee67aa253..54f89f0de 100644 --- a/src/lib/C4Random.cpp +++ b/src/lib/C4Random.cpp @@ -23,10 +23,7 @@ #include -#pragma push_macro("new") -#undef new #include -#pragma pop_macro("new") int RandomCount = 0; diff --git a/src/lib/Standard.h b/src/lib/Standard.h index 9b4acf7e7..01e533988 100644 --- a/src/lib/Standard.h +++ b/src/lib/Standard.h @@ -21,8 +21,6 @@ #define INC_STANDARD #include -#pragma push_macro("new") -#undef new // The Clear/Default functions that exist on most OpenClonk classes are A // BAD IDEA because the caller has no guarantee that every member has been @@ -39,7 +37,6 @@ inline InplaceReconstruct(T *obj) obj->~T(); new (obj) T(); } -#pragma pop_macro("new") #include "platform/PlatformAbstraction.h"