From: havoc Date: Wed, 15 Jan 2003 13:01:21 +0000 (+0000) Subject: added developer_memory cvar (default off) to decide whether to print memory debugging... X-Git-Tag: RELEASE_0_2_0_RC1~20 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=53ffc01f08cc3a88091a966034600eef4a8e2c99;p=xonotic%2Fdarkplaces.git added developer_memory cvar (default off) to decide whether to print memory debugging messages if developer is on git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2688 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/zone.c b/zone.c index 941f9327..19632437 100644 --- a/zone.c +++ b/zone.c @@ -21,6 +21,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "quakedef.h" +cvar_t developer_memory = {0, "developer_memory", "0"}; + mempool_t *poolchain = NULL; void *_Mem_Alloc(mempool_t *pool, int size, const char *filename, int fileline) @@ -34,7 +36,8 @@ void *_Mem_Alloc(mempool_t *pool, int size, const char *filename, int fileline) return NULL; if (pool == NULL) Sys_Error("Mem_Alloc: pool == NULL (alloc at %s:%i)", filename, fileline); - Con_DPrintf("Mem_Alloc: pool %s, file %s:%i, size %i bytes\n", pool->name, filename, fileline, size); + if (developer.integer && developer_memory.integer) + Con_Printf("Mem_Alloc: pool %s, file %s:%i, size %i bytes\n", pool->name, filename, fileline, size); pool->totalsize += size; #if MEMCLUMPING if (size < 4096) @@ -136,7 +139,8 @@ void _Mem_Free(void *data, const char *filename, int fileline) if (*((qbyte *) mem + sizeof(memheader_t) + mem->size) != MEMHEADER_SENTINEL2) Sys_Error("Mem_Free: trashed header sentinel 2 (alloc at %s:%i, free at %s:%i)", mem->filename, mem->fileline, filename, fileline); pool = mem->pool; - Con_DPrintf("Mem_Free: pool %s, alloc %s:%i, free %s:%i, size %i bytes\n", pool->name, mem->filename, mem->fileline, filename, fileline, mem->size); + if (developer.integer && developer_memory.integer) + Con_Printf("Mem_Free: pool %s, alloc %s:%i, free %s:%i, size %i bytes\n", pool->name, mem->filename, mem->fileline, filename, fileline, mem->size); // unlink memheader from doubly linked list if ((mem->prev ? mem->prev->next != mem : pool->chain != mem) || (mem->next && mem->next->prev != mem)) Sys_Error("Mem_Free: not allocated or double freed (free at %s:%i)", filename, fileline); @@ -402,5 +406,6 @@ void Memory_Init_Commands (void) { Cmd_AddCommand ("memstats", MemStats_f); Cmd_AddCommand ("memlist", MemList_f); + Cvar_RegisterVariable (&developer_memory); }