|
UFO: Alien Invasion
|
Memory handling with sentinel checking and pools with tags for grouped free'ing. More...
#include "../shared/cxx.h"

Go to the source code of this file.
Macros | |
| #define | Mem_CreatePool(name) _Mem_CreatePool((name),__FILE__,__LINE__) |
| #define | Mem_DeletePool(pool) _Mem_DeletePool((pool),__FILE__,__LINE__) |
| #define | Mem_Free(ptr) _Mem_Free((ptr),__FILE__,__LINE__) |
| #define | Mem_FreeTag(pool, tagNum) _Mem_FreeTag((pool),(tagNum),__FILE__,__LINE__) |
| #define | Mem_FreePool(pool) _Mem_FreePool((pool),__FILE__,__LINE__) |
| #define | Mem_AllocTypeN(type, n) static_cast<type*>(Mem_Alloc(sizeof(type) * (n))) |
| #define | Mem_AllocType(type) static_cast<type*>(Mem_Alloc(sizeof(type))) |
| #define | Mem_Alloc(size) Mem_PoolAlloc((size), com_genericPool, 0) |
| #define | Mem_PoolAlloc(size, pool, tagNum) _Mem_Alloc((size),true,(pool),(tagNum),__FILE__,__LINE__) |
| #define | Mem_PoolAllocTypeN(type, n, pool) static_cast<type*>(Mem_PoolAlloc(sizeof(type) * (n), (pool), 0)) |
| #define | Mem_PoolAllocType(type, pool) static_cast<type*>(Mem_PoolAllocTypeN(type, 1, (pool))) |
| #define | Mem_ReAlloc(ptr, size) _Mem_ReAlloc((ptr),(size),__FILE__,__LINE__) |
| #define | Mem_SafeReAlloc(ptr, size) ((ptr) ? Mem_ReAlloc(ptr, size) : Mem_Alloc(size)) |
| #define | Mem_Dup(type, in, n) static_cast<type*>(_Mem_PoolDup(1 ? (in) : static_cast<type*>(0) /* type check */, sizeof(type) * (n), com_genericPool, 0, __FILE__, __LINE__)) |
| #define | Mem_StrDup(in) _Mem_PoolStrDup((in),com_genericPool,0,__FILE__,__LINE__) |
| #define | Mem_PoolStrDupTo(in, out, pool, tagNum) _Mem_PoolStrDupTo((in),(out),(pool),(tagNum),__FILE__,__LINE__) |
| #define | Mem_PoolStrDup(in, pool, tagNum) _Mem_PoolStrDup((in),(pool),(tagNum),__FILE__,__LINE__) |
| #define | Mem_PoolSize(pool) _Mem_PoolSize((pool)) |
| #define | Mem_ChangeTag(pool, tagFrom, tagTo) _Mem_ChangeTag((pool),(tagFrom),(tagTo)) |
| #define | Mem_CheckGlobalIntegrity() _Mem_CheckGlobalIntegrity(__FILE__,__LINE__) |
Functions | |
| memPool_t * | _Mem_CreatePool (const char *name, const char *fileName, const int fileLine) __attribute__((malloc)) |
| void | _Mem_DeletePool (memPool_t *pool, const char *fileName, const int fileLine) |
| void | _Mem_Free (void *ptr, const char *fileName, const int fileLine) |
| void | _Mem_FreeTag (memPool_t *pool, const int tagNum, const char *fileName, const int fileLine) |
| Free memory blocks assigned to a specified tag within a pool. More... | |
| void | _Mem_FreePool (memPool_t *pool, const char *fileName, const int fileLine) |
| Free all items within a pool. More... | |
| void * | _Mem_Alloc (size_t size, bool zeroFill, memPool_t *pool, const int tagNum, const char *fileName, const int fileLine) __attribute__((malloc)) |
| Optionally returns 0 filled memory allocated in a pool with a tag. More... | |
| void * | _Mem_ReAlloc (void *ptr, size_t size, const char *fileName, const int fileLine) |
| char * | _Mem_PoolStrDupTo (const char *in, char **out, memPool_t *pool, const int tagNum, const char *fileName, const int fileLine) |
| Saves a string to client hunk. More... | |
| void * | _Mem_PoolDup (const void *in, size_t size, memPool_t *pool, const int tagNum, const char *fileName, const int fileLine) |
| char * | _Mem_PoolStrDup (const char *in, memPool_t *pool, const int tagNum, const char *fileName, const int fileLine) __attribute__((malloc)) |
| No need to null terminate the extra spot because Mem_Alloc returns zero-filled memory. More... | |
| uint32_t | _Mem_PoolSize (memPool_t *pool) |
| uint32_t | _Mem_ChangeTag (memPool_t *pool, const int tagFrom, const int tagTo) |
| void | _Mem_CheckGlobalIntegrity (const char *fileName, const int fileLine) |
| bool | _Mem_AllocatedInPool (memPool_t *pool, const void *pointer) |
| void | Mem_Init (void) |
| void | Mem_Shutdown (void) |
Memory handling with sentinel checking and pools with tags for grouped free'ing.
Definition in file mem.h.
| #define Mem_Alloc | ( | size | ) | Mem_PoolAlloc((size), com_genericPool, 0) |
| #define Mem_ChangeTag | ( | pool, | |
| tagFrom, | |||
| tagTo | |||
| ) | _Mem_ChangeTag((pool),(tagFrom),(tagTo)) |
| #define Mem_CheckGlobalIntegrity | ( | ) | _Mem_CheckGlobalIntegrity(__FILE__,__LINE__) |
| #define Mem_CreatePool | ( | name | ) | _Mem_CreatePool((name),__FILE__,__LINE__) |
| #define Mem_DeletePool | ( | pool | ) | _Mem_DeletePool((pool),__FILE__,__LINE__) |
| #define Mem_Dup | ( | type, | |
| in, | |||
| n | |||
| ) | static_cast<type*>(_Mem_PoolDup(1 ? (in) : static_cast<type*>(0) /* type check */, sizeof(type) * (n), com_genericPool, 0, __FILE__, __LINE__)) |
| #define Mem_FreePool | ( | pool | ) | _Mem_FreePool((pool),__FILE__,__LINE__) |
| #define Mem_FreeTag | ( | pool, | |
| tagNum | |||
| ) | _Mem_FreeTag((pool),(tagNum),__FILE__,__LINE__) |
| #define Mem_PoolAlloc | ( | size, | |
| pool, | |||
| tagNum | |||
| ) | _Mem_Alloc((size),true,(pool),(tagNum),__FILE__,__LINE__) |
| #define Mem_PoolAllocType | ( | type, | |
| pool | |||
| ) | static_cast<type*>(Mem_PoolAllocTypeN(type, 1, (pool))) |
| #define Mem_PoolAllocTypeN | ( | type, | |
| n, | |||
| pool | |||
| ) | static_cast<type*>(Mem_PoolAlloc(sizeof(type) * (n), (pool), 0)) |
| #define Mem_PoolSize | ( | pool | ) | _Mem_PoolSize((pool)) |
| #define Mem_PoolStrDup | ( | in, | |
| pool, | |||
| tagNum | |||
| ) | _Mem_PoolStrDup((in),(pool),(tagNum),__FILE__,__LINE__) |
| #define Mem_PoolStrDupTo | ( | in, | |
| out, | |||
| pool, | |||
| tagNum | |||
| ) | _Mem_PoolStrDupTo((in),(out),(pool),(tagNum),__FILE__,__LINE__) |
| #define Mem_ReAlloc | ( | ptr, | |
| size | |||
| ) | _Mem_ReAlloc((ptr),(size),__FILE__,__LINE__) |
| #define Mem_SafeReAlloc | ( | ptr, | |
| size | |||
| ) | ((ptr) ? Mem_ReAlloc(ptr, size) : Mem_Alloc(size)) |
| #define Mem_StrDup | ( | in | ) | _Mem_PoolStrDup((in),com_genericPool,0,__FILE__,__LINE__) |
| void * _Mem_Alloc | ( | size_t | size, |
| bool | zeroFill, | ||
| memPool_t * | pool, | ||
| const int | tagNum, | ||
| const char * | fileName, | ||
| const int | fileLine | ||
| ) |
Optionally returns 0 filled memory allocated in a pool with a tag.
Definition at line 56 of file cl_game_campaign.cpp.
References cgame_import_t::Alloc(), memBlock_t::allocFile, memBlock_t::allocLine, memPool_t::blockCount, memPool_t::blocks, memBlock_t::botSentinel, memPool_t::byteCount, cgi, Mem_BlockToFooter(), Mem_BlockToPtr(), MEM_FOOT_SENTINEL, MEM_HASH, MEM_HEAD_SENTINEL_BOT, MEM_HEAD_SENTINEL_TOP, memBlock_t::memSize, memBlock_t::next, memBlock_t::pool, memBlockFoot_t::sentinel, Sys_Error(), memBlock_t::tagNum, memBlock_t::topSentinel, UFO_SIZE_T, and z_lock.
Referenced by _Mem_PoolDup(), _Mem_PoolStrDup(), _Mem_ReAlloc(), GAME_GetImportData(), and SV_TagAlloc().
Searches a given pointer in all memory pool blocks
| pool | The pool to search the pointer in |
| pointer | The pointer to search in the pool |
Definition at line 482 of file mem.cpp.
References memPool_t::blocks, Mem_BlockToPtr(), MEM_HASH, memBlock_t::next, and pointer.
Referenced by UI_FreeStringProperty(), and UI_ResetData().
Definition at line 422 of file mem.cpp.
References memPool_t::blocks, MEM_HASH, and memBlock_t::next.
Definition at line 466 of file mem.cpp.
References _Mem_CheckPoolIntegrity(), i, memPool_t::inUse, m_numPools, and m_poolList.
Definition at line 103 of file mem.cpp.
References memPool_t::blockCount, memPool_t::blocks, memPool_t::byteCount, Com_Printf(), memPool_t::createFile, memPool_t::createLine, i, memPool_t::inUse, m_numPools, m_poolList, Mem_FindPool(), MEM_HASH, MEM_MAX_POOLCOUNT, MEM_MAX_POOLNAME, name, memPool_t::name, Q_strncpyz(), and Sys_Error().
Definition at line 146 of file mem.cpp.
References _Mem_FreePool(), memPool_t::inUse, and memPool_t::name.
Definition at line 204 of file mem.cpp.
References _Mem_CheckSentinels(), memPool_t::blockCount, memPool_t::blocks, memPool_t::byteCount, Mem_BlockRawSize(), MEM_HASH, Mem_PtrToBlock(), memBlock_t::next, memBlock_t::pool, and z_lock.
Referenced by _Mem_FreePool(), _Mem_FreeTag(), _Mem_ReAlloc(), FS_FreeFile(), and SV_MemFree().
Free all items within a pool.
Definition at line 260 of file mem.cpp.
References _Mem_Free(), memPool_t::blockCount, memPool_t::blocks, memPool_t::byteCount, Mem_BlockToPtr(), and MEM_HASH.
Referenced by _Mem_DeletePool().
Free memory blocks assigned to a specified tag within a pool.
Definition at line 241 of file mem.cpp.
References _Mem_Free(), memPool_t::blocks, Mem_BlockToPtr(), and MEM_HASH.
Referenced by SV_FreeTags().
| void * _Mem_PoolDup | ( | const void * | in, |
| size_t | size, | ||
| memPool_t * | pool, | ||
| const int | tagNum, | ||
| const char * | fileName, | ||
| const int | fileLine | ||
| ) |
Definition at line 385 of file mem.cpp.
References _Mem_Alloc().
| uint32_t _Mem_PoolSize | ( | memPool_t * | pool | ) |
| [in] | pool | The pool to get the size from |
Definition at line 414 of file mem.cpp.
References memPool_t::byteCount.
| char * _Mem_PoolStrDup | ( | const char * | in, |
| memPool_t * | pool, | ||
| const int | tagNum, | ||
| const char * | fileName, | ||
| const int | fileLine | ||
| ) |
No need to null terminate the extra spot because Mem_Alloc returns zero-filled memory.
| [in] | in | String to store in the given pool |
| [in] | pool | The pool to allocate the memory in |
| [in] | tagNum | |
| [in] | fileName | The filename where this function was called from |
| [in] | fileLine | The line where this function was called from |
Definition at line 403 of file mem.cpp.
References _Mem_Alloc().
Referenced by _Mem_PoolStrDupTo().
| char * _Mem_PoolStrDupTo | ( | const char * | in, |
| char ** | out, | ||
| memPool_t * | pool, | ||
| const int | tagNum, | ||
| const char * | fileName, | ||
| const int | fileLine | ||
| ) |
Saves a string to client hunk.
| [in] | in | String to store in the given pool |
| [out] | out | The location where you want the pool pointer to be stored |
| [in] | pool | The pool to allocate the memory in |
| [in] | tagNum | |
| [in] | fileName | The filename where this function was called from |
| [in] | fileLine | The line where this function was called from |
Definition at line 377 of file mem.cpp.
References _Mem_PoolStrDup().
Definition at line 329 of file mem.cpp.
References _Mem_Alloc(), _Mem_CheckSentinels(), _Mem_Free(), Mem_PtrToBlock(), memBlock_t::memSize, memBlock_t::pool, Sys_Error(), and memBlock_t::tagNum.
Definition at line 588 of file mem.cpp.
References Cmd_AddCommand(), and z_lock.
Referenced by main(), Qcommon_Init(), and TEST_Init().
Definition at line 603 of file mem.cpp.
References i, memPool_t::inUse, m_numPools, m_poolList, Mem_DeletePool, and z_lock.
Referenced by Exit(), main(), Qcommon_Shutdown(), Sys_Error(), Sys_Quit(), TEST_Shutdown(), and Usage().