|
UFO: Alien Invasion
|
Memory handling with sentinel checking and pools with tags for grouped free'ing. More...

Go to the source code of this file.
Data Structures | |
| struct | memBlockFoot_t |
| struct | memBlock_t |
| struct | memPool_t |
Macros | |
| #define | MEM_MAX_POOLNAME 64 |
| #define | MEM_HASH 11 |
| #define | MEM_HEAD_SENTINEL_TOP 0xFEBDFAED |
| #define | MEM_HEAD_SENTINEL_BOT 0xD0BAF0FF |
| #define | MEM_FOOT_SENTINEL 0xF00DF00D |
| #define | MEM_MAX_POOLCOUNT 32 |
Functions | |
| static memPool_t * | Mem_FindPool (const char *name) |
| memPool_t * | _Mem_CreatePool (const char *name, const char *fileName, const int fileLine) |
| void | _Mem_DeletePool (memPool_t *pool, const char *fileName, const int fileLine) |
| static memBlock_t * | Mem_PtrToBlock (void *const ptr) |
| static void * | Mem_BlockToPtr (memBlock_t *const mem) |
| static memBlockFoot_t * | Mem_BlockToFooter (memBlock_t *const mem) |
| static size_t | Mem_BlockRawSize (memBlock_t const *const mem) |
| static void | _Mem_CheckSentinels (memBlock_t *const mem, 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. | |
| void | _Mem_FreePool (memPool_t *pool, const char *fileName, const int fileLine) |
| Free all items within a pool. | |
| 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. | |
| 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. | |
| 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) |
| No need to null terminate the extra spot because Mem_Alloc returns zero-filled memory. | |
| uint32_t | _Mem_PoolSize (memPool_t *pool) |
| uint32_t | _Mem_ChangeTag (memPool_t *pool, const int tagFrom, const int tagTo) |
| static void | _Mem_CheckPoolIntegrity (memPool_t *pool, const char *fileName, const int fileLine) |
| 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) |
Variables | |
| static SDL_mutex * | z_lock |
| static memPool_t | m_poolList [MEM_MAX_POOLCOUNT] |
| static uint32_t | m_numPools |
Memory handling with sentinel checking and pools with tags for grouped free'ing.
Definition in file mem.cpp.
| #define MEM_FOOT_SENTINEL 0xF00DF00D |
Definition at line 70 of file mem.cpp.
Referenced by _Mem_Alloc(), and _Mem_CheckSentinels().
| #define MEM_HASH 11 |
Definition at line 33 of file mem.cpp.
Referenced by _Mem_Alloc(), _Mem_AllocatedInPool(), _Mem_ChangeTag(), _Mem_CheckPoolIntegrity(), _Mem_CreatePool(), _Mem_Free(), _Mem_FreePool(), and _Mem_FreeTag().
| #define MEM_HEAD_SENTINEL_BOT 0xD0BAF0FF |
Definition at line 69 of file mem.cpp.
Referenced by _Mem_Alloc(), and _Mem_CheckSentinels().
| #define MEM_HEAD_SENTINEL_TOP 0xFEBDFAED |
Definition at line 68 of file mem.cpp.
Referenced by _Mem_Alloc(), and _Mem_CheckSentinels().
| #define MEM_MAX_POOLCOUNT 32 |
Definition at line 74 of file mem.cpp.
Referenced by _Mem_CreatePool().
| #define MEM_MAX_POOLNAME 64 |
Definition at line 32 of file mem.cpp.
Referenced by _Mem_CreatePool().
| 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 281 of file mem.cpp.
References memBlock_t::allocFile, memBlock_t::allocLine, memPool_t::blockCount, memPool_t::blocks, memBlock_t::botSentinel, memPool_t::byteCount, 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(), and _Mem_ReAlloc().
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 486 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 426 of file mem.cpp.
References memPool_t::blocks, MEM_HASH, and memBlock_t::next.
Definition at line 470 of file mem.cpp.
References _Mem_CheckPoolIntegrity(), i, memPool_t::inUse, m_numPools, and m_poolList.
Definition at line 445 of file mem.cpp.
References _Mem_CheckSentinels(), memPool_t::blockCount, memPool_t::blocks, memPool_t::byteCount, Mem_BlockRawSize(), MEM_HASH, memBlock_t::next, and Sys_Error().
Referenced by _Mem_CheckGlobalIntegrity().
|
static |
Definition at line 183 of file mem.cpp.
References memBlock_t::allocFile, memBlock_t::allocLine, memBlock_t::botSentinel, Mem_BlockToFooter(), MEM_FOOT_SENTINEL, MEM_HEAD_SENTINEL_BOT, MEM_HEAD_SENTINEL_TOP, memPool_t::name, memBlock_t::pool, Sys_Error(), and memBlock_t::topSentinel.
Referenced by _Mem_CheckPoolIntegrity(), _Mem_Free(), and _Mem_ReAlloc().
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, memPool_t::name, 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 262 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 243 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 389 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 418 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 407 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 381 of file mem.cpp.
References _Mem_PoolStrDup().
Definition at line 333 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.
|
static |
Definition at line 178 of file mem.cpp.
References memBlock_t::memSize.
Referenced by _Mem_CheckPoolIntegrity(), and _Mem_Free().
|
static |
Definition at line 173 of file mem.cpp.
References Mem_BlockToPtr(), and memBlock_t::memSize.
Referenced by _Mem_Alloc(), and _Mem_CheckSentinels().
|
static |
Definition at line 168 of file mem.cpp.
Referenced by _Mem_Alloc(), _Mem_AllocatedInPool(), _Mem_FreePool(), _Mem_FreeTag(), and Mem_BlockToFooter().
|
static |
Definition at line 83 of file mem.cpp.
References i, memPool_t::inUse, m_numPools, m_poolList, memPool_t::name, name, and Q_streq.
Referenced by _Mem_CreatePool().
Definition at line 506 of file mem.cpp.
References Sys_Error(), and z_lock.
Referenced by main(), Qcommon_Init(), and TEST_Init().
|
static |
Definition at line 163 of file mem.cpp.
Referenced by _Mem_Free(), and _Mem_ReAlloc().
Definition at line 518 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(), and TEST_Shutdown().
|
static |
Definition at line 77 of file mem.cpp.
Referenced by _Mem_CheckGlobalIntegrity(), _Mem_CreatePool(), Mem_FindPool(), and Mem_Shutdown().
|
static |
Definition at line 76 of file mem.cpp.
Referenced by _Mem_CheckGlobalIntegrity(), _Mem_CreatePool(), Mem_FindPool(), and Mem_Shutdown().
|
static |
Definition at line 72 of file mem.cpp.
Referenced by _Mem_Alloc(), _Mem_Free(), Mem_Init(), and Mem_Shutdown().