From c26bf6b561ea64b22c6c42b988f10e99677e5dc2 Mon Sep 17 00:00:00 2001 From: Carsten Larsen Date: Sat, 4 Feb 2017 15:35:32 +0100 Subject: [PATCH] Fix MSVC++ memory allocation --- amath.vcxproj | 7 ++++--- amath.vcxproj.filters | 5 ++++- lib/clib/memoo.cpp | 13 +++++++++++-- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/amath.vcxproj b/amath.vcxproj index f6a93b22..c69a2ab8 100644 --- a/amath.vcxproj +++ b/amath.vcxproj @@ -64,6 +64,7 @@ + @@ -213,7 +214,7 @@ {21BD69A9-7F52-48D9-9846-6943E90A87A9} Win32Proj amath - 10.0.10586.0 + 10.0.10240.0 @@ -276,7 +277,7 @@ Level3 Disabled - ANSICONSOLE;WITHTEST;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + WITHTEST;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) app;lib @@ -290,7 +291,7 @@ Level3 Disabled - ANSICONSOLE;WITHTEST;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + WITHTEST;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) app;lib diff --git a/amath.vcxproj.filters b/amath.vcxproj.filters index 8bf9e009..a4946496 100644 --- a/amath.vcxproj.filters +++ b/amath.vcxproj.filters @@ -402,6 +402,9 @@ lib\real + + lib\clib + @@ -600,4 +603,4 @@ lib\real - + \ No newline at end of file diff --git a/lib/clib/memoo.cpp b/lib/clib/memoo.cpp index 47407e6a..4fa410e8 100644 --- a/lib/clib/memoo.cpp +++ b/lib/clib/memoo.cpp @@ -35,11 +35,20 @@ void operator delete (void* ptr) { FreeMemSafe(ptr); } void operator delete[] (void* ptr) { FreeMemSafe(ptr); } #endif -/* GCC 3+ and Windows */ -#if (__GNUC__ > 2) || defined (_WIN32) +/* GCC 3+ */ +#if (__GNUC__ > 2) #include void* operator new (size_t size) throw(std::bad_alloc) { return AllocMemSafe(size); } void* operator new[] (size_t size) throw(std::bad_alloc) { return AllocMemSafe(size); } void operator delete (void* ptr) throw() { FreeMemSafe(ptr); } void operator delete[] (void* ptr) throw() { FreeMemSafe(ptr); } #endif + +/* MSVC++ */ +#if defined (_WIN32) +#include +void* __CRTDECL operator new (size_t size) { return AllocMemSafe(size); } +void* __CRTDECL operator new[] (size_t size) { return AllocMemSafe(size); } +void __CRTDECL operator delete (void* ptr) throw() { FreeMemSafe(ptr); } +void __CRTDECL operator delete[] (void* ptr) throw() { FreeMemSafe(ptr); } +#endif