-
Notifications
You must be signed in to change notification settings - Fork 10
/
MemTest.h
53 lines (42 loc) · 1.5 KB
/
MemTest.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
#ifndef EXTERNAL_RELEASE
#define MEM_LEAK_TEST
#endif
#ifdef MEM_LEAK_TEST
#ifndef __MEM_TEST__H__
#define __MEM_TEST__H__
#pragma warning(disable:4786)
#pragma warning(disable:4291)
#include <windows.h>
#ifdef __cplusplus
extern "C" {
#endif
void* MemTest_malloc(size_t size, char* filename, int line);
void* MemTest_realloc(void* ptr, size_t size, char* filename, int line);
void MemTest_AddLeak(char* Comment);
void MemTest_free(void* ptr);
LPVOID MemTest_VirtualAlloc(LPVOID lpAddress, SIZE_T dwSize,DWORD flAllocationType,DWORD flProtect, LPCSTR filename, int line);
BOOL MemTest_VirtualFree( LPVOID lpAddress, SIZE_T dwSize, DWORD dwFreeType );
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
void* operator new (size_t size );
void* operator new (size_t size, char* filename, int line);
void* operator new [] (size_t size );
void* operator new [] (size_t size, char* filename, int line);
void operator delete ( void* ptr);
void operator delete[](void* ptr);
#undef new
#define new new(__FILE__, __LINE__)
#endif
#endif
#undef malloc
#undef free
#define malloc(x) (MemTest_malloc((x),__FILE__, __LINE__))
#define realloc(mem,x) (MemTest_realloc((mem),(x),__FILE__, __LINE__))
#define free(x) (MemTest_free (x))
#define VirtualAlloc(lpAddress, dwSize, flAllocationType, flProtect ) \
(MemTest_VirtualAlloc((lpAddress), (dwSize), (flAllocationType), (flProtect),__FILE__, __LINE__))
#define VirtualFree(lpAddress, dwSize, dwFreeType ) \
(MemTest_VirtualFree((lpAddress), (dwSize), (dwFreeType)))
#endif