/** * @brief Makes sure the game DLL does not use client, or signed tags */ static void *SV_TagAlloc (int size, int tagNum, const char *file, int line) { if (tagNum < 0) tagNum *= -1; return _Mem_Alloc(size, qtrue, sv->gameSysPool, tagNum, file, line); }
/** * @brief No need to null terminate the extra spot because Mem_Alloc returns zero-filled memory * @param[in] in String to store in the given pool * @param[in] pool The pool to allocate the memory in * @param[in] tagNum * @param[in] fileName The filename where this function was called from * @param[in] fileLine The line where this function was called from */ char *_Mem_PoolStrDup (const char *in, memPool_t *pool, const int tagNum, const char *fileName, const int fileLine) { char *out; out = (char *)_Mem_Alloc((size_t)(strlen(in) + 1), true, pool, tagNum, fileName, fileLine); strcpy(out, in); return out; }
char *_TVCopyString_Pool( mempool_t *pool, const char *in, const char *filename, int fileline ) { char *out; out = _Mem_Alloc( pool, sizeof( char ) * ( strlen( in ) + 1 ), 0, 0, filename, fileline ); //out = Mem_ZoneMalloc( sizeof(char) * (strlen(in) + 1) ); //Q_strncpyz( out, in, sizeof(char) * (strlen(in) + 1) ); strcpy( out, in ); return out; }
void *_Mem_PoolDup (const void *in, size_t size, memPool_t *pool, const int tagNum, const char *fileName, const int fileLine) { void *copy; assert(in != nullptr); assert(size > 0); copy = _Mem_Alloc(size, false, pool, tagNum, fileName, fileLine); memcpy(copy, in, size); return copy; }
char *_Mem_CopyString( mempool_t *pool, const char *in, const char *filename, int fileline ) { char *out; size_t num_chars = strlen( in ) + 1; size_t str_size = sizeof( char ) * num_chars; out = ( char* )_Mem_Alloc( pool, str_size, 0, 0, filename, fileline ); memcpy( out, in, str_size ); return out; }
char *_copystring( byte *mempool, const char *s, const char *filename, int fileline ) { char *b; if( !s ) return NULL; if( !mempool ) mempool = host.mempool; b = _Mem_Alloc( mempool, Q_strlen( s ) + 1, filename, fileline ); Q_strcpy( b, s ); return b; }
void *_Mem_ReAlloc (void *ptr, size_t size, const char *fileName, const int fileLine) { memPool_t *pool; void *newPtr; if (!size) Sys_Error("Use Mem_Free instead"); if (!ptr) Sys_Error("Use Mem_Alloc instead"); memBlock_t* const mem = Mem_PtrToBlock(ptr); _Mem_CheckSentinels(mem, fileName, fileLine); /* if size matches, do nothing */ if (mem->memSize == size) return ptr; pool = mem->pool; /* allocate memory for the new size */ newPtr = _Mem_Alloc(size, false, pool, mem->tagNum, fileName, fileLine); /* copy old data */ memcpy(newPtr, ptr, std::min(mem->memSize, size)); if (mem->memSize < size) { const size_t delta = size - mem->memSize; memset((byte*)newPtr + mem->memSize, 0, delta); } /* if there was old data, free it */ _Mem_Free(ptr, fileName, fileLine); _Mem_CheckSentinels(Mem_PtrToBlock(newPtr), fileName, fileLine); return newPtr; }
// Function name : GetNTProcessInfo // Description : // Return type : BOOL // Argument : CHAR** ppInfoBuff BOOL GetNTProcessInfo(CHAR** ppInfoBuff) { DWORD dwBuffSize; DWORD dwResult; dwBuffSize = 1024*32; do { if(!(*ppInfoBuff = (CHAR*) _Mem_Alloc(dwBuffSize))) break; dwResult = pZwQuerySystemInformation((DWORD)5, *ppInfoBuff, dwBuffSize, NULL); if(dwResult == 0) break; else { // STATUS_BUFFER_OVERFLOW || status == STATUS_INFO_LENGTH_MISMATCH if(dwResult == 0x80000005L || dwResult == 0xC0000004L) { _Mem_Free(*ppInfoBuff); *ppInfoBuff = NULL; dwBuffSize += 0x2000; } else { _Mem_Free(*ppInfoBuff); *ppInfoBuff = NULL; break; } } } while(TRUE); if (*ppInfoBuff == NULL) return FALSE; return TRUE; }
/* * CL_CinModule_MemAlloc */ static void *CL_CinModule_MemAlloc( mempool_t *pool, size_t size, const char *filename, int fileline ) { return _Mem_Alloc( pool, size, MEMPOOL_CINMODULE, 0, filename, fileline ); }
/* * PF_MemAlloc */ static void *PF_MemAlloc( size_t size, const char *filename, int fileline ) { return _Mem_Alloc( sv_gameprogspool, size, MEMPOOL_GAMEPROGS, 0, filename, fileline ); }
/* * CL_SoundModule_MemAlloc */ static void *CL_SoundModule_MemAlloc( mempool_t *pool, int size, const char *filename, int fileline ) { return _Mem_Alloc( pool, size, MEMPOOL_SOUND, 0, filename, fileline ); }
static void *Com_ScriptModule_MemAlloc( mempool_t *pool, int size, const char *filename, int fileline ) { return _Mem_Alloc( pool, size, MEMPOOL_ANGELSCRIPT, 0, filename, fileline ); }
/* * CL_UIModule_MemAlloc */ static void *CL_UIModule_MemAlloc( size_t size, const char *filename, int fileline ) { return _Mem_Alloc( ui_mempool, size, MEMPOOL_USERINTERFACE, 0, filename, fileline ); }
/* * TV_Module_MemAlloc */ static void *TV_Module_MemAlloc( relay_t *relay, size_t size, const char *filename, int fileline ) { return _Mem_Alloc( relay->module_mempool, size, MEMPOOL_GAMEPROGS, 0, filename, fileline ); }
/* * CL_GameModule_MemAlloc */ static void *CL_GameModule_MemAlloc( size_t size, const char *filename, int fileline ) { return _Mem_Alloc( cl_gamemodulepool, size, MEMPOOL_CLIENTGAME, 0, filename, fileline ); }
static void *Irc_MemAlloc( int size, const char *filename, int fileline ) { return _Mem_Alloc( irc_pool, size, 0, 0, filename, fileline ); }
static void *R_Mem_Alloc( size_t cb, const char *filename, const int fileline ) { return _Mem_Alloc( cls.mempool, cb, filename, fileline ); }