Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DWORD dwXmemLeaks = 0;
- void *dwXmemory = NULL;
- DWORD xmemleaks() { return dwXmemLeaks; }
- void xmemlock() { HeapLock(dwXmemory); }
- void xmemunlock() { HeapUnlock(dwXmemory); }
- BYTE xmemvalidate(void *ptr) { return (BYTE)HeapValidate(dwXmemory, 0, ptr); }
- DWORD xmemsize(void *ptr) { return (DWORD)HeapSize(dwXmemory, 0, ptr); }
- void *xalloc(DWORD dwSize)
- {
- if (dwXmemory == NULL) dwXmemory = HeapCreate(0, 0, 0);
- dwXmemLeaks++;
- return HeapAlloc(dwXmemory, HEAP_ZERO_MEMORY, dwSize);
- }
- void *xrealloc(void *ptr, DWORD dwSize)
- {
- return HeapReAlloc(dwXmemory, HEAP_ZERO_MEMORY, ptr, dwSize);
- }
- void xfree(void *ptr)
- {
- dwXmemLeaks--;
- HeapFree(dwXmemory, HEAP_ZERO_MEMORY, ptr);
- if (dwXmemLeaks == 0) { HeapDestroy(dwXmemory); dwXmemory = NULL; }
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement