Starshatter_Open
Open source Starshatter engine
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
MemDebug.h
Go to the documentation of this file.
1 /* Project FoundationEx
2  Destroyer Studios LLC
3  Copyright © 1997-2004. All Rights Reserved.
4 
5  SUBSYSTEM: FoundationEx
6  FILE: MemDebug.h
7  AUTHOR: John DiCamillo
8 
9 
10  OVERVIEW
11  ========
12  Memory Debugging class
13 */
14 
15 
16 #ifndef MemDebug_h
17 #define MemDebug_h
18 
19 // +--------------------------------------------------------------------+
20 
21 #ifdef WIN32
22 #include <windows.h>
23 #include <windowsx.h>
24 #endif
25 
26 #ifdef FOUNDATION_USE_MFC
27 
28 #ifndef _DEBUG
29 
30 inline void* __cdecl operator new(unsigned int s, const char*, int) { return ::operator new(s); }
31 inline void __cdecl operator delete(void* p, const char*, int) { ::operator delete(p); }
32 
33 #else
34 
35 void* __cdecl operator new(unsigned int s, const char*, int);
36 void __cdecl operator delete(void* p, const char*, int);
37 
38 #endif
39 
40 #else
41 
42 //
43 // MEMORY DEBUGGING NOT SUPPORTED UNDER MFC
44 //
45 
46 // +--------------------------------------------------------------------+
47 
48 class Memory
49 {
50 public:
52 
53  static void OpenLog(const char* filename=0);
54  static void CloseLog();
55 
56  static void Check();
57  static void Checkpoint();
58  static void Stats();
59  static void DumpLeaks();
60 
61  static void SetLevel(LEVEL l);
62 };
63 
64 // +--------------------------------------------------------------------+
65 
66 #ifndef _DEBUG
67 
68 inline void* __cdecl operator new(unsigned int s, const char*, int) { return ::operator new(s); }
69 inline void __cdecl operator delete(void* p, const char*, int) { ::operator delete(p); }
70 
71 #else
72 /*_CRTIMP*/
73 void* __cdecl operator new(unsigned int, int, const char*, int);
74 
75 inline void* __cdecl operator new(unsigned int s, const char* f, int l)
76  { return ::operator new(s, 1, f, l); }
77 
78 inline void* __cdecl operator new(unsigned int s)
79  { return ::operator new(s, 1, __FILE__, __LINE__); }
80 
81 inline void __cdecl operator delete(void* p, const char*, int)
82  { ::operator delete(p); }
83 
84 #endif _DEBUG
85 
86 // +--------------------------------------------------------------------+
87 
88 #endif FOUNDATION_USE_MFC
89 
90 #endif MemDebug_h
91