mirror of
https://github.com/nzp-team/fteqw.git
synced 2025-02-22 19:41:27 +00:00
fixing a bug, and making easier to find memory corruptions BEFORE the pointers are freed.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@280 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
dc559bf6df
commit
e5cc1ba3c3
1 changed files with 43 additions and 9 deletions
|
@ -318,29 +318,63 @@ void Zone_Print_f(void)
|
||||||
int overhead=0;
|
int overhead=0;
|
||||||
int allocated = 0;
|
int allocated = 0;
|
||||||
int blocks = 0;
|
int blocks = 0;
|
||||||
int futurehide;
|
int futurehide = false;
|
||||||
|
int i;
|
||||||
|
qbyte *sent;
|
||||||
zone_t *zone;
|
zone_t *zone;
|
||||||
if (*Cmd_Argv(1))
|
#if MEMDEBUG > 0
|
||||||
futurehide = true;
|
qboolean testsent = false;
|
||||||
|
if (*Cmd_Argv(1) == 't')
|
||||||
|
{
|
||||||
|
Con_Printf("Testing Zone sentinels\n");
|
||||||
|
testsent = true;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
futurehide = false;
|
#endif
|
||||||
|
if (*Cmd_Argv(1))
|
||||||
|
futurehide = true;
|
||||||
for(zone = zone_head; zone; zone=zone->next)
|
for(zone = zone_head; zone; zone=zone->next)
|
||||||
{
|
{
|
||||||
blocks++;
|
blocks++;
|
||||||
allocated+= zone->size;
|
allocated+= zone->size;
|
||||||
|
|
||||||
#ifdef NAMEDMALLOCS
|
#ifdef NAMEDMALLOCS
|
||||||
if (*((char *)(zone+1)+zone->size)!='#')
|
if (*((char *)(zone+1)+zone->size+MEMDEBUG*2)!='#')
|
||||||
{
|
{
|
||||||
Con_Printf("%i-%s\n", zone->size, (char *)(zone+1) + zone->size);
|
#if MEMDEBUG > 0
|
||||||
|
if (testsent)
|
||||||
|
{
|
||||||
|
sent = (qbyte *)(zone+1);
|
||||||
|
for (i = 0; i < MEMDEBUG; i++)
|
||||||
|
{
|
||||||
|
if (sent[i] != sentinalkey)
|
||||||
|
{
|
||||||
|
Con_Printf("^1%i %i-%s\n", zone->size, i, (char *)(zone+1) + zone->size+MEMDEBUG*2);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sent += zone->size+MEMDEBUG;
|
||||||
|
for (i = 0; i < MEMDEBUG; i++)
|
||||||
|
{
|
||||||
|
if (sent[i] != sentinalkey)
|
||||||
|
{
|
||||||
|
Con_Printf("^1%i %i-%s\n", zone->size, i, (char *)(zone+1) + zone->size+MEMDEBUG*2);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
Con_Printf("%i-%s\n", zone->size, (char *)(zone+1) + zone->size+MEMDEBUG*2);
|
||||||
if (futurehide)
|
if (futurehide)
|
||||||
*((char *)(zone+1)+zone->size) = '#';
|
*((char *)(zone+1)+zone->size+MEMDEBUG*2) = '#';
|
||||||
|
|
||||||
// Sleep(10);
|
// Sleep(10);
|
||||||
}
|
}
|
||||||
overhead += sizeof(zone) + strlen((char *)(zone+1) + zone->size) +1;
|
overhead += sizeof(zone_t)+MEMDEBUG*2 + strlen((char *)(zone+1) + zone->size+MEMDEBUG*2) +1;
|
||||||
#else
|
#else
|
||||||
Con_Printf("%i-%i ", zone->size, zone->tag);
|
Con_Printf("%i-%i ", zone->size, zone->tag);
|
||||||
overhead += sizeof(zone);
|
overhead += sizeof(zone_t)+MEMDEBUG*2;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
Con_Printf("Zone:%i bytes in %i blocks\n", allocated, blocks);
|
Con_Printf("Zone:%i bytes in %i blocks\n", allocated, blocks);
|
||||||
|
|
Loading…
Reference in a new issue