gldebug.h

00001 /*
00002 Copyright (c) 2000-2007 Lee Thomason (www.grinninglizard.com)
00003 Grinning Lizard Utilities.
00004 
00005 This software is provided 'as-is', without any express or implied 
00006 warranty. In no event will the authors be held liable for any 
00007 damages arising from the use of this software.
00008 
00009 Permission is granted to anyone to use this software for any 
00010 purpose, including commercial applications, and to alter it and 
00011 redistribute it freely, subject to the following restrictions:
00012 
00013 1. The origin of this software must not be misrepresented; you must 
00014 not claim that you wrote the original software. If you use this 
00015 software in a product, an acknowledgment in the product documentation 
00016 would be appreciated but is not required.
00017 
00018 2. Altered source versions must be plainly marked as such, and 
00019 must not be misrepresented as being the original software.
00020 
00021 3. This notice may not be removed or altered from any source 
00022 distribution.
00023 */
00024 
00025 
00026 
00027 #ifndef GRINLIZ_DEBUG_INCLUDED
00028 #define GRINLIZ_DEBUG_INCLUDED
00029 
00030 #if defined( _DEBUG ) && !defined( DEBUG )
00031         #define DEBUG
00032 #endif
00033 
00034 #if defined(DEBUG)
00035         #ifdef _MSC_VER
00036                 void dprintf( const char* format, ... );
00037                 void WinDebugBreak();
00038                 
00039                 #define GLASSERT( x )           if ( !(x)) WinDebugBreak()
00040                 #define GLOUTPUT( x )           dprintf x
00041                 #define GLLOG( x )                      dprintf x
00042         #else
00043                 #include <assert.h>
00044         #include <stdio.h>
00045                 #define GLASSERT                assert
00046                 #define GLOUTPUT( x )   printf x        
00047                 #define GLLOG( x )              printf x
00048         #endif
00049 #else
00050 
00051         #if defined(UNIX)
00052                 #define GLOUTPUT( x )
00053         #else
00054                 #define GLOUTPUT( x )
00055         #endif
00056 
00057         #define GLASSERT( x )
00058         #define GLLOG( x )                      printf x
00059 
00060 #endif
00061 
00062 #if defined(DEBUG)
00063         #define GRINLIZ_DEBUG_MEM
00064         //#define GRINLIZ_DEBUG_MEM_DEEP
00065 
00066         #ifdef GRINLIZ_DEBUG_MEM
00067                 void* DebugNew( size_t size, bool arrayType, const char* name, int line );
00068                 
00069                 inline void* operator new[]( size_t size, const char* file, int line ) {
00070                         return DebugNew( size, true, file, line );
00071                 }
00072 
00073                 inline void* operator new( size_t size, const char* file, int line ) {
00074                         return DebugNew( size, false, file, line );
00075                 }
00076 
00077                 void MemLeakCheck();
00078                 void MemStartCheck();
00079                 void MemHeapCheck();
00080                 #define glnew new(__FILE__, __LINE__)
00081         #else
00082                 #define glnew new
00083                 inline void MemLeakCheck()      {}
00084                 inline void MemStartCheck()     {}
00085                 inline void MemHeapCheck()      {}
00086         #endif
00087 #else
00088         #define glnew new
00089         inline void MemLeakCheck()      {}
00090         inline void MemStartCheck()     {}
00091 #endif
00092 
00093 #endif // file

Generated on Fri Mar 23 19:36:21 2007 for Lilith3D by  doxygen 1.5.1-p1