revive MSVC10 memleak checking and fix a few memleaks

Sven Eberhardt 2010-12-07 23:43:00 +01:00
parent f73fa5e645
commit e2a580fd55
8 changed files with 48 additions and 38 deletions

View File

@ -1567,7 +1567,7 @@ void C4Game::Default()
ScenarioLangStringTable.Default();
ScenarioSysLangStringTable.Default();
Script.Default();
GraphicsResource.Default();
//GraphicsResource.Default();
//Control.Default();
MouseControl.Default();
PathFinder.Default();

View File

@ -56,6 +56,34 @@
// solidmask debugging
//#define SOLIDMASK_DEBUG
// boost headers
#include <boost/function.hpp>
#include <boost/bind.hpp>
// debug memory management - must come after boost headers,
// because boost uses placement new
#ifndef NODEBUGMEM
#if defined(_DEBUG) && defined(_MSC_VER)
#if _MSC_VER <= 1200
#include <new>
#include <memory>
#include <crtdbg.h>
#include <malloc.h>
#define malloc(size) ::_malloc_dbg(size, _NORMAL_BLOCK, __FILE__, __LINE__)
#else
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#endif
inline void *operator new(unsigned int 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 <algorithm>
#include <cassert>
#include <cctype>

View File

@ -22,8 +22,6 @@
#include "StdSync.h"
#include "StdWindow.h"
#include <boost/function.hpp>
// Event types
enum C4InteractiveEventType
{

View File

@ -18,6 +18,7 @@
* "Clonk" is a registered trademark of Matthes Bender.
* See clonk_trademark_license.txt for full license.
*/
#include "C4Include.h"
#include "C4Network2IRC.h"
#include "C4Config.h"
@ -26,8 +27,6 @@
#include "C4Gui.h" // for clearly visi
#include <boost/bind.hpp>
#include <cctype> // for isdigit
// Helper for IRC command parameter parsing

View File

@ -29,6 +29,15 @@
#include <config.h>
#endif // HAVE_CONFIG_H
#ifdef _MSC_VER
#define DEPRECATED __declspec(deprecated)
#elif defined(__GNUC__)
#define DEPRECATED __attribute__((deprecated))
#else
#define DEPRECATED
#endif
#ifdef _WIN32
# ifndef _INC_WINDOWS
# ifdef _WIN64
@ -60,38 +69,6 @@
#ifdef _MSC_VER
#define DEPRECATED __declspec(deprecated)
#elif defined(__GNUC__)
#define DEPRECATED __attribute__((deprecated))
#else
#define DEPRECATED
#endif
// debug memory management
#ifndef NODEBUGMEM
#if defined(_DEBUG) && defined(_MSC_VER)
#if _MSC_VER <= 1200
#include <new>
#include <memory>
#include <crtdbg.h>
#include <malloc.h>
inline void *operator new(unsigned int 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 new(__FILE__, __LINE__)
#define malloc(size) ::_malloc_dbg(size, _NORMAL_BLOCK, __FILE__, __LINE__)
#else
#include <crtdbg.h>
#endif
#endif
#endif
// C++0x nullptr
#ifdef HAVE_NULLPTR
#undef NULL

View File

@ -403,6 +403,13 @@ public:
IDs->push_back(this);
}
virtual ~IDBase()
{
assert(IDs);
IDs->erase(std::find(IDs->begin(), IDs->end(), this));
if (!IDs->size()) { delete IDs; IDs = NULL; }
}
public:
const char* name;
const std::type_info& type;

View File

@ -318,6 +318,7 @@ bool CSurface::CreateTextures(int MaxTextureSize)
#ifdef _DEBUG
static int dbg_counter = 0;
if (dbg_idx) delete dbg_idx;
dbg_idx = new int;
*dbg_idx = dbg_counter++;
#endif

View File

@ -71,7 +71,7 @@ bool CStdWindow::RegisterWindowClass(HINSTANCE hInst)
WndClass.lpszClassName = C4FullScreenClassName;
WndClass.hIcon = LoadIcon (hInst, MAKEINTRESOURCE (IDI_00_C4X) );
WndClass.hIconSm = LoadIcon (hInst, MAKEINTRESOURCE (IDI_00_C4X) );
return RegisterClassExW(&WndClass);
return !!RegisterClassExW(&WndClass);
}
#define ADDL2(s) L##s