/******************************************************************************** Copyright (C) 2001-2012 Hugh Bailey This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. ********************************************************************************/ #include "XT.h" #include "malloc.h" //wow, this thing is horrible. this thing is so horrible. I seriously need to fix it. //----------------------------------------- //Allocation tracking struct struct Allocation { DWORD allocationID; LPVOID Address; TCHAR lpFile[1024]; DWORD dwLine; }; Allocation *AllocationList = NULL; DWORD numAllocations = 0; DWORD totalAllocations = 0; DWORD allocationCounter = 0; unsigned int dwAllocCurLine; TCHAR * lpAllocCurFile; BOOL bEnableTracking = FALSE; int memoryBreakID; void EnableMemoryTracking(BOOL bEnable, int id) { bEnableTracking = bEnable; memoryBreakID = id; } void SetMemoryBreakID(int id) { memoryBreakID = id; } DebugAlloc::DebugAlloc() { hDebugMutex = OSCreateMutex(); } DebugAlloc::~DebugAlloc() { OSCloseMutex(hDebugMutex); if(numAllocations) { Log(TEXT("%d Memory leaks detected on exit!\r\n"), numAllocations); Log(TEXT("Allocation Tracking Results: Memory Leaks:\r\n=========================================================\r\n")); for(DWORD i=0;i