From 1582ae9dbf00ce57fa30dd99a810fe603ed30775 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 8 Feb 2013 13:29:17 +0100 Subject: [PATCH] Changed: Preliminary memory leaks detection under Windows --- code/nel/src/misc/co_task.cpp | 8 ++++++++ code/nel/src/misc/common.cpp | 6 ++++++ code/nel/src/misc/config_file/config_file.cpp | 5 +++++ code/nel/src/misc/contiguous_block_allocator.cpp | 5 +++++ code/nel/src/misc/debug.cpp | 9 ++++++++- code/nel/src/misc/displayer.cpp | 5 +++++ code/nel/src/misc/fixed_size_allocator.cpp | 7 ++++++- code/nel/src/misc/heap_memory.cpp | 4 ++++ code/nel/src/misc/log.cpp | 7 ++++++- code/nel/src/misc/object_arena_allocator.cpp | 4 ++++ 10 files changed, 57 insertions(+), 3 deletions(-) diff --git a/code/nel/src/misc/co_task.cpp b/code/nel/src/misc/co_task.cpp index 8fdfb6449..91b0132a9 100644 --- a/code/nel/src/misc/co_task.cpp +++ b/code/nel/src/misc/co_task.cpp @@ -15,9 +15,13 @@ // along with this program. If not, see . #include "stdmisc.h" + +#include "nel/misc/types_nl.h" #include "nel/misc/co_task.h" #include "nel/misc/tds.h" #include "nel/misc/time_nl.h" +#include "nel/misc/debug.h" + // Flag to use thread instead of coroutine primitives (i.e windows fibers or gcc context) #ifndef NL_OS_WINDOWS #define NL_USE_THREAD_COTASK @@ -59,6 +63,10 @@ #endif #endif //NL_USE_THREAD_COTASK +#ifdef DEBUG_NEW + #define new DEBUG_NEW +#endif + namespace NLMISC { diff --git a/code/nel/src/misc/common.cpp b/code/nel/src/misc/common.cpp index 347569976..36e167260 100644 --- a/code/nel/src/misc/common.cpp +++ b/code/nel/src/misc/common.cpp @@ -16,6 +16,9 @@ #include "stdmisc.h" +#include "nel/misc/types_nl.h" +#include "nel/misc/common.h" + #ifdef NL_OS_WINDOWS # define NOMINMAX # include @@ -68,6 +71,9 @@ extern "C" long _ftol2( double dblSource ) { return _ftol( dblSource ); } #endif // NL_OS_WINDOWS +#ifdef DEBUG_NEW + #define new DEBUG_NEW +#endif namespace NLMISC { diff --git a/code/nel/src/misc/config_file/config_file.cpp b/code/nel/src/misc/config_file/config_file.cpp index f502d327e..6113a7a2c 100644 --- a/code/nel/src/misc/config_file/config_file.cpp +++ b/code/nel/src/misc/config_file/config_file.cpp @@ -14,6 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . +#include "../stdmisc.h" #include "nel/misc/config_file.h" #include @@ -27,6 +28,10 @@ #include "nel/misc/mem_stream.h" #include "locale.h" +#ifdef DEBUG_NEW + #define new DEBUG_NEW +#endif + using namespace std; using namespace NLMISC; diff --git a/code/nel/src/misc/contiguous_block_allocator.cpp b/code/nel/src/misc/contiguous_block_allocator.cpp index 7d4ae1e0f..6db4b0d63 100644 --- a/code/nel/src/misc/contiguous_block_allocator.cpp +++ b/code/nel/src/misc/contiguous_block_allocator.cpp @@ -15,8 +15,13 @@ // along with this program. If not, see . #include "stdmisc.h" + #include "nel/misc/contiguous_block_allocator.h" +#ifdef DEBUG_NEW + #define new DEBUG_NEW +#endif + namespace NLMISC { diff --git a/code/nel/src/misc/debug.cpp b/code/nel/src/misc/debug.cpp index b37f16d57..28f40f641 100644 --- a/code/nel/src/misc/debug.cpp +++ b/code/nel/src/misc/debug.cpp @@ -16,6 +16,9 @@ #include "stdmisc.h" +#include "nel/misc/types_nl.h" +#include "nel/misc/debug.h" + #ifdef HAVE_NELCONFIG_H # include "nelconfig.h" #endif // HAVE_NELCONFIG_H @@ -27,6 +30,7 @@ #include "nel/misc/report.h" #include "nel/misc/path.h" #include "nel/misc/variable.h" +#include "nel/misc/system_info.h" #ifdef NL_OS_WINDOWS # define _WIN32_WINDOWS 0x0410 @@ -79,6 +83,9 @@ using namespace std; // If true, debug system will trap crash even if the application is in debugger static const bool TrapCrashInDebugger = false; +#ifdef DEBUG_NEW + #define new DEBUG_NEW +#endif namespace NLMISC { @@ -90,7 +97,7 @@ namespace NLMISC bool DisableNLDebug= false; NLMISC::CVariablePtr _DisableNLDebug("nel","DisableNLDebug","Disables generation and output of nldebug logs (no code associated with the log generation is executed)",&DisableNLDebug,true); -static std::string LogPath = ""; +static std::string LogPath; //bool DebugNeedAssert = false; //bool NoAssert = false; diff --git a/code/nel/src/misc/displayer.cpp b/code/nel/src/misc/displayer.cpp index d8b8f0306..d91193759 100644 --- a/code/nel/src/misc/displayer.cpp +++ b/code/nel/src/misc/displayer.cpp @@ -16,6 +16,7 @@ #include "stdmisc.h" +#include "nel/misc/types_nl.h" #ifdef NL_OS_WINDOWS # include @@ -49,6 +50,10 @@ using namespace std; +#ifdef DEBUG_NEW + #define new DEBUG_NEW +#endif + namespace NLMISC { diff --git a/code/nel/src/misc/fixed_size_allocator.cpp b/code/nel/src/misc/fixed_size_allocator.cpp index f16e87dd4..790275ec6 100644 --- a/code/nel/src/misc/fixed_size_allocator.cpp +++ b/code/nel/src/misc/fixed_size_allocator.cpp @@ -15,8 +15,13 @@ // along with this program. If not, see . #include "stdmisc.h" -#include "nel/misc/fixed_size_allocator.h" +#include "nel/misc/fixed_size_allocator.h" +#include "nel/misc/debug.h" + +#ifdef DEBUG_NEW + #define new DEBUG_NEW +#endif namespace NLMISC { diff --git a/code/nel/src/misc/heap_memory.cpp b/code/nel/src/misc/heap_memory.cpp index de9f794f2..0c3918ba0 100644 --- a/code/nel/src/misc/heap_memory.cpp +++ b/code/nel/src/misc/heap_memory.cpp @@ -17,9 +17,13 @@ #include "stdmisc.h" #include "nel/misc/heap_memory.h" +#include "nel/misc/debug.h" using namespace std; +#ifdef DEBUG_NEW + #define new DEBUG_NEW +#endif namespace NLMISC { diff --git a/code/nel/src/misc/log.cpp b/code/nel/src/misc/log.cpp index ee7cc67c0..85ec59e04 100644 --- a/code/nel/src/misc/log.cpp +++ b/code/nel/src/misc/log.cpp @@ -16,6 +16,8 @@ #include "stdmisc.h" +#include "nel/misc/log.h" + #ifdef NL_OS_WINDOWS # define NOMINMAX # include @@ -31,6 +33,9 @@ using namespace std; +#ifdef DEBUG_NEW + #define new DEBUG_NEW +#endif namespace NLMISC { @@ -430,7 +435,7 @@ void CLog::displayRawString (const char *str) (*idi)->display( *args, disp ); } } - TempString = ""; + TempString.clear(); unsetPosition(); } diff --git a/code/nel/src/misc/object_arena_allocator.cpp b/code/nel/src/misc/object_arena_allocator.cpp index 35a786c1a..9c73f5059 100644 --- a/code/nel/src/misc/object_arena_allocator.cpp +++ b/code/nel/src/misc/object_arena_allocator.cpp @@ -18,6 +18,10 @@ #include "nel/misc/object_arena_allocator.h" #include "nel/misc/fixed_size_allocator.h" +#ifdef DEBUG_NEW + #define new DEBUG_NEW +#endif + namespace NLMISC {