-
Notifications
You must be signed in to change notification settings - Fork 0
/
leaks.h
65 lines (51 loc) · 1.46 KB
/
leaks.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <stdlib.h>
#define new DEBUG_NEW
#ifdef _DEBUG
struct ALLOC_INFO
{
unsigned int address;
unsigned int size;
char file[_MAX_PATH];
unsigned int line;
ALLOC_INFO *pNext;
};
void RemoveTrack (unsigned int addr);
void AddTrack (unsigned int addr, unsigned int asize, const char *fname, unsigned int lnum);
inline void *__cdecl operator new (unsigned int size, const char *file, int line)
{
void *ptr = (void *)malloc(size);
AddTrack((unsigned int)ptr, size, file, line);
return(ptr);
};
inline void __cdecl operator delete(void* p, const char* pszFilename, int nLine)
{
RemoveTrack((unsigned int)p);
free(p);
}
inline void __cdecl operator delete (void *p)
{
RemoveTrack((unsigned int)p);
free(p);
};
inline void * __cdecl operator new [] (unsigned int size, const char *file, int line)
{
void *ptr = (void *)malloc(size);
AddTrack((unsigned int)ptr, size, file, line);
return(ptr);
};
inline void __cdecl operator delete [] (void *p)
{
RemoveTrack((unsigned int)p);
free(p);
}
void DumpUnfreed();
extern ALLOC_INFO *g_LeakList;
#endif
#ifdef _DEBUG
#define DEBUG_NEW new(__FILE__, __LINE__)
#else
#define DEBUG_NEW new
#endif
#ifdef _DEBUG
#define DISPOSE(p) delete p; RemoveTrack((unsigned int)p);
#endif