Initial source commit
This commit is contained in:
commit
f1384c11ee
335 changed files with 52715 additions and 0 deletions
127
minorGems/util/development/memory/debugMemory.h
Normal file
127
minorGems/util/development/memory/debugMemory.h
Normal file
|
@ -0,0 +1,127 @@
|
|||
/*
|
||||
* Modification History
|
||||
*
|
||||
* 2002-October-17 Jason Rohrer
|
||||
* Created.
|
||||
*
|
||||
* 2002-October-18 Jason Rohrer
|
||||
* Added static initialization counting class for MemoryTrack.
|
||||
*
|
||||
* 2002-October-20 Jason Rohrer
|
||||
* Removed delete macro trick that was causing crashes in tinyxml.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef DEBUG_MEMORY_INCLUDED
|
||||
#define DEBUG_MEMORY_INCLUDED
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef DEBUG_MEMORY
|
||||
|
||||
#include "minorGems/util/development/memory/MemoryTrack.h"
|
||||
|
||||
|
||||
|
||||
// internal function prototypes
|
||||
void *debugMemoryNew( unsigned int inSize,
|
||||
const char *inFileName, int inLine );
|
||||
|
||||
void *debugMemoryNewArray( unsigned int inSize,
|
||||
const char *inFileName, int inLine );
|
||||
|
||||
void debugMemoryDelete( void *inPointer );
|
||||
|
||||
void debugMemoryDeleteArray( void *inPointer );
|
||||
|
||||
|
||||
|
||||
// overrided primitive operators... must be inline?
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Overrides the new operator to track memory allocations.
|
||||
*
|
||||
* @param inSize the size of the allocation.
|
||||
* @param inFileName the name of the source file where the allocation
|
||||
* occurred.
|
||||
* @param inLine the line in the source file where the allocation occurred.
|
||||
*/
|
||||
inline void *operator new( unsigned int inSize,
|
||||
const char *inFileName, int inLine ) {
|
||||
return debugMemoryNew( inSize, inFileName, inLine );
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Overrides the new [] operator to track memory allocations.
|
||||
*
|
||||
* @param inSize the size of the allocation.
|
||||
* @param inFileName the name of the source file where the allocation
|
||||
* occurred.
|
||||
* @param inLine the line in the source file where the allocation occurred.
|
||||
*/
|
||||
inline void * operator new [] ( unsigned int inSize,
|
||||
const char *inFileName, int inLine ) {
|
||||
|
||||
return debugMemoryNewArray( inSize, inFileName, inLine );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Overrides the delete operator to track memory allocations.
|
||||
*
|
||||
* @param inPointer a pointer to the memory to deallocate.
|
||||
*/
|
||||
inline void operator delete( void *inPointer ) {
|
||||
debugMemoryDelete( inPointer );
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Overrides the delete [] operator to track memory allocations.
|
||||
*
|
||||
* @param inPointer a pointer to the memory to deallocate.
|
||||
*/
|
||||
inline void operator delete [] ( void *inPointer ) {
|
||||
debugMemoryDeleteArray( inPointer );
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// macro trickery to pass file name and line number into new
|
||||
|
||||
#ifdef DEBUG_MEMORY
|
||||
#define DEBUG_NEW new( __FILE__, __LINE__ )
|
||||
#else
|
||||
#define DEBUG_NEW new
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define new DEBUG_NEW
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue