00001 /* 00002 =========================================================================== 00003 Copyright (C) 1999-2005 Id Software, Inc. 00004 00005 This file is part of Quake III Arena source code. 00006 00007 Quake III Arena source code is free software; you can redistribute it 00008 and/or modify it under the terms of the GNU General Public License as 00009 published by the Free Software Foundation; either version 2 of the License, 00010 or (at your option) any later version. 00011 00012 Quake III Arena source code is distributed in the hope that it will be 00013 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with Foobar; if not, write to the Free Software 00019 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00020 =========================================================================== 00021 */ 00022 00023 /***************************************************************************** 00024 * name: l_memory.h 00025 * 00026 * desc: memory management 00027 * 00028 * $Archive: /source/code/botlib/l_memory.h $ 00029 * 00030 *****************************************************************************/ 00031 00032 //#define MEMDEBUG 00033 00034 #ifdef MEMDEBUG 00035 #define GetMemory(size) GetMemoryDebug(size, #size, __FILE__, __LINE__); 00036 #define GetClearedMemory(size) GetClearedMemoryDebug(size, #size, __FILE__, __LINE__); 00037 //allocate a memory block of the given size 00038 void *GetMemoryDebug(unsigned long size, char *label, char *file, int line); 00039 //allocate a memory block of the given size and clear it 00040 void *GetClearedMemoryDebug(unsigned long size, char *label, char *file, int line); 00041 // 00042 #define GetHunkMemory(size) GetHunkMemoryDebug(size, #size, __FILE__, __LINE__); 00043 #define GetClearedHunkMemory(size) GetClearedHunkMemoryDebug(size, #size, __FILE__, __LINE__); 00044 //allocate a memory block of the given size 00045 void *GetHunkMemoryDebug(unsigned long size, char *label, char *file, int line); 00046 //allocate a memory block of the given size and clear it 00047 void *GetClearedHunkMemoryDebug(unsigned long size, char *label, char *file, int line); 00048 #else 00049 //allocate a memory block of the given size 00050 void *GetMemory(unsigned long size); 00051 //allocate a memory block of the given size and clear it 00052 void *GetClearedMemory(unsigned long size); 00053 // 00054 #ifdef BSPC 00055 #define GetHunkMemory GetMemory 00056 #define GetClearedHunkMemory GetClearedMemory 00057 #else 00058 //allocate a memory block of the given size 00059 void *GetHunkMemory(unsigned long size); 00060 //allocate a memory block of the given size and clear it 00061 void *GetClearedHunkMemory(unsigned long size); 00062 #endif 00063 #endif 00064 00065 //free the given memory block 00066 void FreeMemory(void *ptr); 00067 //returns the amount available memory 00068 int AvailableMemory(void); 00069 //prints the total used memory size 00070 void PrintUsedMemorySize(void); 00071 //print all memory blocks with label 00072 void PrintMemoryLabels(void); 00073 //returns the size of the memory block in bytes 00074 int MemoryByteSize(void *ptr); 00075 //free all allocated memory 00076 void DumpMemory(void);
1.3.9.1