1 /* 2 =========================================================================== 3 4 Return to Castle Wolfenstein single player GPL Source Code 5 Copyright (C) 1999-2010 id Software LLC, a ZeniMax Media company. 6 7 This file is part of the Return to Castle Wolfenstein single player GPL Source Code (RTCW SP Source Code). 8 9 RTCW SP Source Code is free software: you can redistribute it and/or modify 10 it under the terms of the GNU General Public License as published by 11 the Free Software Foundation, either version 3 of the License, or 12 (at your option) any later version. 13 14 RTCW SP Source Code is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with RTCW SP Source Code. If not, see <http://www.gnu.org/licenses/>. 21 22 In addition, the RTCW SP Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the RTCW SP Source Code. If not, please request a copy in writing from id Software at the address below. 23 24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA. 25 26 =========================================================================== 27 */ 28 29 30 /***************************************************************************** 31 * name: l_memory.h 32 * 33 * desc: memory management 34 * 35 * 36 *****************************************************************************/ 37 38 #ifdef _DEBUG 39 #ifndef BSPC 40 #define MEMDEBUG 41 #endif 42 #endif 43 44 #ifdef MEMDEBUG 45 #define GetMemory( size ) GetMemoryDebug( size, # size, __FILE__, __LINE__ ); 46 #define GetClearedMemory( size ) GetClearedMemoryDebug( size, # size, __FILE__, __LINE__ ); 47 //allocate a memory block of the given size 48 void *GetMemoryDebug( unsigned long size, char *label, char *file, int line ); 49 //allocate a memory block of the given size and clear it 50 void *GetClearedMemoryDebug( unsigned long size, char *label, char *file, int line ); 51 // 52 #define GetHunkMemory( size ) GetHunkMemoryDebug( size, # size, __FILE__, __LINE__ ); 53 #define GetClearedHunkMemory( size ) GetClearedHunkMemoryDebug( size, # size, __FILE__, __LINE__ ); 54 //allocate a memory block of the given size 55 void *GetHunkMemoryDebug( unsigned long size, char *label, char *file, int line ); 56 //allocate a memory block of the given size and clear it 57 void *GetClearedHunkMemoryDebug( unsigned long size, char *label, char *file, int line ); 58 #else 59 //allocate a memory block of the given size 60 void *GetMemory( unsigned long size ); 61 //allocate a memory block of the given size and clear it 62 void *GetClearedMemory( unsigned long size ); 63 // 64 #ifdef BSPC 65 #define GetHunkMemory GetMemory 66 #define GetClearedHunkMemory GetClearedMemory 67 #else 68 //allocate a memory block of the given size 69 void *GetHunkMemory( unsigned long size ); 70 //allocate a memory block of the given size and clear it 71 void *GetClearedHunkMemory( unsigned long size ); 72 #endif 73 #endif 74 75 //free the given memory block 76 void FreeMemory( void *ptr ); 77 //prints the total used memory size 78 void PrintUsedMemorySize( void ); 79 //print all memory blocks with label 80 void PrintMemoryLabels( void ); 81 //returns the size of the memory block in bytes 82 int MemoryByteSize( void *ptr ); 83 //free all allocated memory 84 void DumpMemory( void ); 85