1
0
Fork 0
forked from fte/fteqw

special sentinal checking and a small optimisation.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@509 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2004-11-23 00:31:46 +00:00
parent 6317634447
commit 85e7fc3987

View file

@ -34,7 +34,7 @@ void Cache_FreeLow (int new_low_hunk);
void Cache_FreeHigh (int new_high_hunk); void Cache_FreeHigh (int new_high_hunk);
#ifdef _DEBUG #ifdef _DEBUG
//#define MEMDEBUG 8192 //Debugging adds sentinels (the number is the size - I have the ram) #define MEMDEBUG 8192 //Debugging adds sentinels (the number is the size - I have the ram)
#endif #endif
#ifndef MEMDEBUG #ifndef MEMDEBUG
@ -174,6 +174,35 @@ void Z_Free (void *c)
free(nz); free(nz);
} }
void BZ_CheckSentinals(void *c)
{
#if MEMDEBUG>0
zone_t *nz;
nz = ((zone_t *)((char*)c-MEMDEBUG))-1;
// Z_CheckSentinals();
{
int i;
qbyte *buf;
buf = (qbyte *)(nz+1);
for (i = 0; i < MEMDEBUG; i++)
{
if (buf[i] != sentinalkey)
*(int*)0 = -3; //force a crash... this'll get our attention.
}
buf+=MEMDEBUG;
//app data
buf += nz->size;
for (i = 0; i < MEMDEBUG; i++)
{
if (buf[i] != sentinalkey)
*(int*)0 = -3; //force a crash... this'll get our attention.
}
}
#endif
}
void Z_FreeTags(int tag) void Z_FreeTags(int tag)
{ {
zone_t *zone, *next; zone_t *zone, *next;
@ -301,11 +330,15 @@ void *BZ_Realloc(void *data, int newsize)
if (!data) if (!data)
return Z_MallocNamed(newsize, file, lineno); return Z_MallocNamed(newsize, file, lineno);
oldzone = ((zone_t *)((char *)data-MEMDEBUG))-1; oldzone = ((zone_t *)((char *)data-MEMDEBUG))-1;
if (oldzone->size == newsize)
return data;
newdata = Z_MallocNamed(newsize, file, lineno); newdata = Z_MallocNamed(newsize, file, lineno);
#else #else
if (!data) if (!data)
return Z_Malloc(newsize); return Z_Malloc(newsize);
oldzone = ((zone_t *)((char *)data-MEMDEBUG))-1; oldzone = ((zone_t *)((char *)data-MEMDEBUG))-1;
if (oldzone->size == newsize)
return data;
newdata = BZ_Malloc(newsize); newdata = BZ_Malloc(newsize);
#endif #endif
if (oldzone->size < newsize) if (oldzone->size < newsize)