From 7b2f842053813c91f9eb846651fc5c7db8134459 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Thu, 8 Dec 2011 22:25:25 +0000 Subject: [PATCH] Show file/line/label in Com_Error messages when run out of memory in debug build. --- code/qcommon/common.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/code/qcommon/common.c b/code/qcommon/common.c index dcc31fd8..6074b33d 100644 --- a/code/qcommon/common.c +++ b/code/qcommon/common.c @@ -966,12 +966,16 @@ void *Z_TagMalloc( int size, int tag ) { do { if (rover == start) { + // scaned all the way around the list #ifdef ZONE_DEBUG Z_LogHeap(); -#endif - // scaned all the way around the list - Com_Error( ERR_FATAL, "Z_Malloc: failed on allocation of %i bytes from the %s zone", + + Com_Error(ERR_FATAL, "Z_Malloc: failed on allocation of %i bytes from the %s zone: %s, line: %d (%s)", + size, zone == smallzone ? "small" : "main", file, line, label); +#else + Com_Error(ERR_FATAL, "Z_Malloc: failed on allocation of %i bytes from the %s zone", size, zone == smallzone ? "small" : "main"); +#endif return NULL; } if (rover->tag) { @@ -1724,8 +1728,11 @@ void *Hunk_Alloc( int size, ha_pref preference ) { #ifdef HUNK_DEBUG Hunk_Log(); Hunk_SmallLog(); + + Com_Error(ERR_DROP, "Hunk_Alloc failed on %i: %s, line: %d (%s)", size, file, line, label); +#else + Com_Error(ERR_DROP, "Hunk_Alloc failed on %i", size); #endif - Com_Error( ERR_DROP, "Hunk_Alloc failed on %i", size ); } if ( hunk_permanent == &hunk_low ) {