1
0
forked from 0ad/0ad

Re-enabled VC's memory debugging by default (when not using USE_MMGR). Hopefully fixed the resulting memory leaks. Also fixed incompatibilities with VC2005.

This was SVN commit r1950.
This commit is contained in:
Ykkrosh 2005-02-27 22:11:26 +00:00
parent 540a76e88b
commit da5816e971
8 changed files with 27 additions and 6 deletions

View File

@ -70,6 +70,12 @@ template<class T, size_t n> struct RingBuf
class const_iterator
{
public:
typedef std::random_access_iterator_tag iterator_category;
typedef T value_type;
typedef ptrdiff_t difference_type;
typedef const T* pointer;
typedef const T& reference;
const_iterator() : data(0), pos(0)
{}
const_iterator(const T* _data, size_t _pos) : data(_data), pos(_pos)
@ -88,6 +94,9 @@ template<class T, size_t n> struct RingBuf
{ return data == rhs.data && pos == rhs.pos; }
bool operator!=(const const_iterator& rhs) const
{ return !(*this == rhs); }
bool operator<(const const_iterator& rhs) const
{ return (pos < rhs.pos); }
protected:
const T* data;
size_t pos;

View File

@ -74,7 +74,9 @@
# ifdef SCED
# define HAVE_DEBUGALLOC
# else
//# define HAVE_DEBUGALLOC // <-- enable this if you want to use it instead of mmgr
# ifndef USE_MMGR
# define HAVE_DEBUGALLOC
# endif
# endif
#endif

View File

@ -16,11 +16,6 @@
#pragma warning(disable:4786) // identifier truncated to 255 chars
#endif
// HACK: Allow compilation on VC2005. (RingBuf doesn't like
// iterator debugging - a better solution would be to fix that.)
#define _HAS_ITERATOR_DEBUGGING 0
//
// memory headers
//

View File

@ -102,6 +102,7 @@ CPlayer *CGame::GetPlayer(uint idx)
// Hmm. This is a bit of a problem.
assert2(! "### ### ### ### ERROR: Tried to access the players list when there aren't any players. That really isn't going to work, so I'll give up. ### ###");
abort();
return NULL; // else VC2005 warns about not returning a value
}
else
return m_Players[0];

View File

@ -235,6 +235,11 @@ CGameAttributes::~CGameAttributes()
delete *it;
++it;
}
// PT: ??? - Gaia isn't a player slot, but still needs to be deleted; but
// this feels rather unpleasantly inconsistent with the above code, so maybe
// there's a better way to avoid the memory leak.
delete m_Players[0];
}
void CGameAttributes::ScriptingInit()

View File

@ -24,6 +24,13 @@ CPlayer::CPlayer(uint playerID):
m_SynchedProperties[L"colour"]=prop;
}
CPlayer::~CPlayer()
{
// Side-effect of HACK - since it's not passed to CJSObject's list, it
// doesn't get freed automatically
delete m_SynchedProperties[L"colour"];
}
void CPlayer::ScriptingInit()
{
AddMethod<jsval, &CPlayer::JSI_ToString>( "toString", 0 );

View File

@ -28,6 +28,7 @@ private:
public:
CPlayer( uint playerID );
~CPlayer();
bool ValidateCommand(CNetMessage *pMsg);

View File

@ -2,6 +2,7 @@
#include "nommgr.h"
#include "XML.h"
#include "nommgr.h" // undefine 'new' a lot, because Xerces doesn't like it
#include "CStr.h"
#include "CLogger.h"