1 /* 2 Copyright (C) 1997-2001 Id Software, Inc. 3 4 This program is free software; you can redistribute it and/or 5 modify it under the terms of the GNU General Public License 6 as published by the Free Software Foundation; either version 2 7 of the License, or (at your option) any later version. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 13 See the GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program; if not, write to the Free Software 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 */ 19 20 // 21 // memory.h 22 // 23 24 #define MEM_USE_CALLOC 1 25 26 // constants 27 #define Mem_CreatePool(name) _Mem_CreatePool((name),__FILE__,__LINE__) 28 #define Mem_DeletePool(pool) _Mem_DeletePool((pool),__FILE__,__LINE__) 29 30 #define Mem_Free(ptr) _Mem_Free((ptr),__FILE__,__LINE__) 31 #define Mem_FreeTag(pool,tagNum) _Mem_FreeTag((pool),(tagNum),__FILE__,__LINE__) 32 #define Mem_FreePool(pool) _Mem_FreePool((pool),__FILE__,__LINE__) 33 #define Mem_Alloc(size) _Mem_Alloc((size),qTrue,com_genericPool,0,__FILE__,__LINE__) 34 #define Mem_AllocExt(size,zeroFill) _Mem_Alloc((size),(zeroFill),com_genericPool,0,__FILE__,__LINE__) 35 #define Mem_PoolAlloc(size,pool,tagNum) _Mem_Alloc((size),qTrue,(pool),(tagNum),__FILE__,__LINE__) 36 #define Mem_PoolAllocExt(size,zeroFill,pool,tagNum) _Mem_Alloc((size),(zeroFill),(pool),(tagNum),__FILE__,__LINE__) 37 38 #define Mem_StrDup(in) _Mem_PoolStrDup((in),com_genericPool,0,__FILE__,__LINE__) 39 #define Mem_PoolStrDup(in,pool,tagNum) _Mem_PoolStrDup((in),(pool),(tagNum),__FILE__,__LINE__) 40 #define Mem_PoolSize(pool) _Mem_PoolSize((pool)) 41 #define Mem_TagSize(pool,tagNum) _Mem_TagSize((pool),(tagNum)) 42 #define Mem_ChangeTag(pool,tagFrom,tagTo) _Mem_ChangeTag((pool),(tagFrom),(tagTo)) 43 44 #define Mem_CheckPoolIntegrity(pool) _Mem_CheckPoolIntegrity((pool),__FILE__,__LINE__) 45 #define Mem_CheckGlobalIntegrity() _Mem_CheckGlobalIntegrity(__FILE__,__LINE__) 46 47 #define Mem_TouchPool(pool) _Mem_TouchPool((pool),__FILE__,__LINE__) 48 #define Mem_TouchGlobal() _Mem_TouchGlobal(__FILE__,__LINE__) 49 50 // functions 51 struct memPool_s *_Mem_CreatePool (const char *name, const char *fileName, const int fileLine); 52 uint32 _Mem_DeletePool (struct memPool_s *pool, const char *fileName, const int fileLine); 53 54 uint32 _Mem_Free (const void *ptr, const char *fileName, const int fileLine); 55 uint32 _Mem_FreeTag (struct memPool_s *pool, const int tagNum, const char *fileName, const int fileLine); 56 uint32 _Mem_FreePool (struct memPool_s *pool, const char *fileName, const int fileLine); 57 void *_Mem_Alloc (size_t size, qBool zeroFill, struct memPool_s *pool, const int tagNum, const char *fileName, const int fileLine); 58 59 char *_Mem_PoolStrDup (const char *in, struct memPool_s *pool, const int tagNum, const char *fileName, const int fileLine); 60 uint32 _Mem_PoolSize (struct memPool_s *pool); 61 uint32 _Mem_TagSize (struct memPool_s *pool, const int tagNum); 62 uint32 _Mem_ChangeTag (struct memPool_s *pool, const int tagFrom, const int tagTo); 63 64 void _Mem_CheckPoolIntegrity (struct memPool_s *pool, const char *fileName, const int fileLine); 65 void _Mem_CheckGlobalIntegrity (const char *fileName, const int fileLine); 66 67 void _Mem_TouchPool (struct memPool_s *pool, const char *fileName, const int fileLine); 68 void _Mem_TouchGlobal (const char *fileName, const int fileLine); 69 70 void Mem_Register (void); 71 void Mem_Init (void); 72