From f8983b2326dd93061c923b0f6c99b17406b00b3c Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 8 Dec 2012 11:40:34 +0100 Subject: [PATCH] Changed: Preliminary memory leaks detection under Windows --- code/nel/src/misc/app_context.cpp | 4 ++++ code/nel/src/misc/bitmap.cpp | 3 +++ code/nel/src/misc/class_registry.cpp | 5 +++++ code/nel/src/misc/cpu_time_stat.cpp | 7 ++++++- code/nel/src/misc/eval_num_expr.cpp | 5 +++++ code/nel/src/misc/file.cpp | 12 +++++++++--- code/nel/src/misc/gtk_displayer.cpp | 7 +++++-- code/nel/src/misc/input_device_server.cpp | 6 +++++- code/nel/src/misc/inter_window_msg_queue.cpp | 8 ++++++-- code/nel/src/misc/mutex.cpp | 4 ++++ code/nel/src/misc/path.cpp | 6 +++++- code/nel/src/misc/progress_callback.cpp | 7 ++++++- code/nel/src/misc/shared_memory.cpp | 5 +++++ code/nel/src/misc/system_info.cpp | 6 ++++++ code/nel/src/misc/tds.cpp | 5 +++++ code/nel/src/misc/time_nl.cpp | 11 +++++++---- code/nel/src/misc/win_displayer.cpp | 7 +++++-- code/nel/src/misc/win_thread.cpp | 6 +++++- 18 files changed, 96 insertions(+), 18 deletions(-) diff --git a/code/nel/src/misc/app_context.cpp b/code/nel/src/misc/app_context.cpp index 1213a6559..a0b35b35a 100644 --- a/code/nel/src/misc/app_context.cpp +++ b/code/nel/src/misc/app_context.cpp @@ -19,6 +19,10 @@ #include "nel/misc/dynloadlib.h" #include "nel/misc/command.h" +#ifdef DEBUG_NEW + #define new DEBUG_NEW +#endif + namespace NLMISC { diff --git a/code/nel/src/misc/bitmap.cpp b/code/nel/src/misc/bitmap.cpp index aa426d47a..cfe8cab89 100644 --- a/code/nel/src/misc/bitmap.cpp +++ b/code/nel/src/misc/bitmap.cpp @@ -26,6 +26,9 @@ using namespace std; +#ifdef DEBUG_NEW + #define new DEBUG_NEW +#endif namespace NLMISC { diff --git a/code/nel/src/misc/class_registry.cpp b/code/nel/src/misc/class_registry.cpp index 74e3e24b9..91c603c90 100644 --- a/code/nel/src/misc/class_registry.cpp +++ b/code/nel/src/misc/class_registry.cpp @@ -17,9 +17,14 @@ #include "stdmisc.h" #include "nel/misc/class_registry.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/cpu_time_stat.cpp b/code/nel/src/misc/cpu_time_stat.cpp index a1f9bc23f..861ab8e56 100644 --- a/code/nel/src/misc/cpu_time_stat.cpp +++ b/code/nel/src/misc/cpu_time_stat.cpp @@ -15,9 +15,10 @@ // along with this program. If not, see . #include "stdmisc.h" -#include "nel/misc/cpu_time_stat.h" +#include "nel/misc/cpu_time_stat.h" #include "nel/misc/common.h" +#include "nel/misc/debug.h" #ifdef NL_OS_UNIX #include @@ -27,6 +28,10 @@ using namespace std; +#ifdef DEBUG_NEW + #define new DEBUG_NEW +#endif + namespace NLMISC { diff --git a/code/nel/src/misc/eval_num_expr.cpp b/code/nel/src/misc/eval_num_expr.cpp index de7f3b2bf..c47309498 100644 --- a/code/nel/src/misc/eval_num_expr.cpp +++ b/code/nel/src/misc/eval_num_expr.cpp @@ -17,6 +17,11 @@ #include "stdmisc.h" #include "nel/misc/eval_num_expr.h" +#include "nel/misc/debug.h" + +#ifdef DEBUG_NEW + #define new DEBUG_NEW +#endif namespace NLMISC { diff --git a/code/nel/src/misc/file.cpp b/code/nel/src/misc/file.cpp index 4c8501a17..842d9ea51 100644 --- a/code/nel/src/misc/file.cpp +++ b/code/nel/src/misc/file.cpp @@ -15,9 +15,7 @@ // along with this program. If not, see . #include "stdmisc.h" -#ifndef NL_OS_WINDOWS -#include -#endif + #include "nel/misc/file.h" #include "nel/misc/debug.h" #include "nel/misc/big_file.h" @@ -26,10 +24,18 @@ #include "nel/misc/sstring.h" #include "nel/misc/xml_pack.h" +#ifndef NL_OS_WINDOWS +#include +#endif + using namespace std; #define NLMISC_DONE_FILE_OPENED 40 +#ifdef DEBUG_NEW + #define new DEBUG_NEW +#endif + namespace NLMISC { diff --git a/code/nel/src/misc/gtk_displayer.cpp b/code/nel/src/misc/gtk_displayer.cpp index d348bab79..f558a4909 100644 --- a/code/nel/src/misc/gtk_displayer.cpp +++ b/code/nel/src/misc/gtk_displayer.cpp @@ -15,6 +15,7 @@ // along with this program. If not, see . #include "stdmisc.h" +#include "nel/misc/gtk_displayer.h" #ifdef NL_USE_GTK @@ -35,10 +36,12 @@ #include "nel/misc/command.h" #include "nel/misc/thread.h" -#include "nel/misc/gtk_displayer.h" - using namespace std; +#ifdef DEBUG_NEW + #define new DEBUG_NEW +#endif + namespace NLMISC { // diff --git a/code/nel/src/misc/input_device_server.cpp b/code/nel/src/misc/input_device_server.cpp index 2b713d836..253b68e71 100644 --- a/code/nel/src/misc/input_device_server.cpp +++ b/code/nel/src/misc/input_device_server.cpp @@ -15,10 +15,14 @@ // along with this program. If not, see . #include "stdmisc.h" + #include "nel/misc/input_device_server.h" #include "nel/misc/input_device.h" +#include "nel/misc/debug.h" - +#ifdef DEBUG_NEW + #define new DEBUG_NEW +#endif namespace NLMISC { diff --git a/code/nel/src/misc/inter_window_msg_queue.cpp b/code/nel/src/misc/inter_window_msg_queue.cpp index 2526f1449..77e72e654 100644 --- a/code/nel/src/misc/inter_window_msg_queue.cpp +++ b/code/nel/src/misc/inter_window_msg_queue.cpp @@ -16,12 +16,16 @@ #include "stdmisc.h" -#ifdef NL_OS_WINDOWS #include "nel/misc/inter_window_msg_queue.h" -// + +#ifdef NL_OS_WINDOWS #include "nel/misc/mem_stream.h" #include "nel/misc/shared_memory.h" +#ifdef DEBUG_NEW + #define new DEBUG_NEW +#endif + namespace NLMISC { diff --git a/code/nel/src/misc/mutex.cpp b/code/nel/src/misc/mutex.cpp index fb337fab6..f8a75d2ea 100644 --- a/code/nel/src/misc/mutex.cpp +++ b/code/nel/src/misc/mutex.cpp @@ -22,6 +22,7 @@ #include "nel/misc/mutex.h" #include "nel/misc/time_nl.h" +#include "nel/misc/debug.h" using namespace std; @@ -47,6 +48,9 @@ using namespace std; #define NOMINMAX #include +#ifdef DEBUG_NEW + #define new DEBUG_NEW +#endif namespace NLMISC { diff --git a/code/nel/src/misc/path.cpp b/code/nel/src/misc/path.cpp index bcef9bdeb..c59aabf0c 100644 --- a/code/nel/src/misc/path.cpp +++ b/code/nel/src/misc/path.cpp @@ -17,8 +17,8 @@ #include "stdmisc.h" -#include "nel/misc/big_file.h" #include "nel/misc/path.h" +#include "nel/misc/big_file.h" #include "nel/misc/hierarchical_timer.h" #include "nel/misc/progress_callback.h" #include "nel/misc/file.h" @@ -48,6 +48,10 @@ using namespace std; +#ifdef DEBUG_NEW + #define new DEBUG_NEW +#endif + namespace NLMISC { // diff --git a/code/nel/src/misc/progress_callback.cpp b/code/nel/src/misc/progress_callback.cpp index 965f25ec1..c4d4841ea 100644 --- a/code/nel/src/misc/progress_callback.cpp +++ b/code/nel/src/misc/progress_callback.cpp @@ -15,8 +15,13 @@ // along with this program. If not, see . #include "stdmisc.h" -#include "nel/misc/progress_callback.h" +#include "nel/misc/progress_callback.h" +#include "nel/misc/debug.h" + +#ifdef DEBUG_NEW + #define new DEBUG_NEW +#endif namespace NLMISC { diff --git a/code/nel/src/misc/shared_memory.cpp b/code/nel/src/misc/shared_memory.cpp index 544ba882a..2a7f85a8b 100644 --- a/code/nel/src/misc/shared_memory.cpp +++ b/code/nel/src/misc/shared_memory.cpp @@ -15,7 +15,9 @@ // along with this program. If not, see . #include "stdmisc.h" + #include "nel/misc/shared_memory.h" +#include "nel/misc/debug.h" #ifdef NL_OS_WINDOWS # define NOMINMAX @@ -28,6 +30,9 @@ using namespace std; +#ifdef DEBUG_NEW + #define new DEBUG_NEW +#endif namespace NLMISC { diff --git a/code/nel/src/misc/system_info.cpp b/code/nel/src/misc/system_info.cpp index a6c1c4bf3..7ef96ec58 100644 --- a/code/nel/src/misc/system_info.cpp +++ b/code/nel/src/misc/system_info.cpp @@ -16,6 +16,8 @@ #include "stdmisc.h" +#include "nel/misc/system_info.h" + #ifdef NL_OS_WINDOWS # define NOMINMAX # include @@ -42,6 +44,10 @@ using namespace std; +#ifdef DEBUG_NEW + #define new DEBUG_NEW +#endif + namespace NLMISC { #ifdef NL_OS_UNIX diff --git a/code/nel/src/misc/tds.cpp b/code/nel/src/misc/tds.cpp index bfc3b6af0..13105f98d 100644 --- a/code/nel/src/misc/tds.cpp +++ b/code/nel/src/misc/tds.cpp @@ -17,12 +17,17 @@ #include "stdmisc.h" #include "nel/misc/tds.h" +#include "nel/misc/debug.h" #ifdef NL_OS_WINDOWS # define NOMINMAX # include #endif // NL_OS_WINDOWS +#ifdef DEBUG_NEW + #define new DEBUG_NEW +#endif + namespace NLMISC { diff --git a/code/nel/src/misc/time_nl.cpp b/code/nel/src/misc/time_nl.cpp index 422ba192f..0ba60c8e2 100644 --- a/code/nel/src/misc/time_nl.cpp +++ b/code/nel/src/misc/time_nl.cpp @@ -16,6 +16,10 @@ #include "stdmisc.h" +#include "nel/misc/time_nl.h" +#include "nel/misc/sstring.h" +#include "nel/misc/thread.h" + #ifdef NL_OS_WINDOWS # define NOMINMAX # include @@ -29,10 +33,9 @@ #include #endif -#include "nel/misc/time_nl.h" -#include "nel/misc/sstring.h" - -#include +#ifdef DEBUG_NEW + #define new DEBUG_NEW +#endif namespace NLMISC { diff --git a/code/nel/src/misc/win_displayer.cpp b/code/nel/src/misc/win_displayer.cpp index d016b4106..f5c0d9545 100644 --- a/code/nel/src/misc/win_displayer.cpp +++ b/code/nel/src/misc/win_displayer.cpp @@ -15,6 +15,7 @@ // along with this program. If not, see . #include "stdmisc.h" +#include "nel/misc/win_displayer.h" #ifdef NL_OS_WINDOWS @@ -33,10 +34,12 @@ #include "nel/misc/thread.h" #include "nel/misc/ucstring.h" -#include "nel/misc/win_displayer.h" - using namespace std; +#ifdef DEBUG_NEW + #define new DEBUG_NEW +#endif + namespace NLMISC { static CHARFORMAT2 CharFormat; diff --git a/code/nel/src/misc/win_thread.cpp b/code/nel/src/misc/win_thread.cpp index eec462d3c..d90d081ff 100644 --- a/code/nel/src/misc/win_thread.cpp +++ b/code/nel/src/misc/win_thread.cpp @@ -15,16 +15,20 @@ // along with this program. If not, see . #include "stdmisc.h" +#include "nel/misc/win_thread.h" #ifdef NL_OS_WINDOWS -#include "nel/misc/win_thread.h" #include "nel/misc/path.h" #define NOMINMAX #include #include +#ifdef DEBUG_NEW + #define new DEBUG_NEW +#endif + namespace NLMISC { CWinThread MainThread ((void*)GetCurrentThread (), GetCurrentThreadId());