move this stuff behind ZDEBUG

This commit is contained in:
Alug committed 2025-07-24 17:03:10 +02:00
1 parent fa012aefe1
commit e15319ac9b
2 files changed
+66 -8

No files matched your search

+56 -8
View File
@@ -394,11 +394,19 @@ void *Z_ReallocAlign(void *ptr, size_t size, INT32 tag, void *user, INT32 alignb
* \param lowtag The lowest tag to consider.
* \param hightag The highest tag to consider.
*/
#ifdef ZDEBUG
void Z_FreeTags2(INT32 lowtag, INT32 hightag, const char *file, INT32 line)
#else
void Z_FreeTags(INT32 lowtag, INT32 hightag)
#endif
{
memblock_t *block, *next;
#ifdef ZDEBUG
Z_CheckHeap2(file, line);
#else
Z_CheckHeap(420);
#endif
for (block = head.next; block != &head; block = next)
{
next = block->next; // get link before freeing
@@ -468,12 +476,20 @@ void Z_CheckMemCleanup(void)
* \param i Identifies from where in the code Z_CheckHeap was called.
* \author Graue <graue@oceanbase.org>
*/
#ifdef ZDEBUG
void Z_CheckHeap2(const char *file, INT32 line)
#else
void Z_CheckHeap(INT32 tag)
#endif
{
memblock_t *block;
UINT32 blocknumon = 0;
void *given;
#ifndef ZDEBUG
(void)tag;
#endif
for (block = head.next; block != &head; block = block->next)
{
blocknumon++;
@@ -498,11 +514,19 @@ void Z_CheckHeap2(const char *file, INT32 line)
#endif
if (block->user != NULL && *(block->user) != given)
{
I_Error("Z_CheckHeap %s %d: block %u"
I_Error("Z_CheckHeap"
#ifdef ZDEBUG
"at %s %d :"
#endif
"block %u"
#ifdef ZDEBUG
"(owned by %s:%d)"
#endif
" doesn't have a proper user", file, line, blocknumon
" doesn't have a proper user"
#ifdef ZDEBUG
, file, line
#endif
, blocknumon
#ifdef ZDEBUG
, block->ownerfile, block->ownerline
#endif
@@ -510,11 +534,19 @@ void Z_CheckHeap2(const char *file, INT32 line)
}
if (block->next->prev != block)
{
I_Error("Z_CheckHeap %s %d: block %u"
I_Error("Z_CheckHeap"
#ifdef ZDEBUG
"at %s %d :"
#endif
"block %u"
#ifdef ZDEBUG
"(owned by %s:%d)"
#endif
" lacks proper backlink", file, line, blocknumon
" lacks proper backlink"
#ifdef ZDEBUG
, file, line
#endif
, blocknumon
#ifdef ZDEBUG
, block->ownerfile, block->ownerline
#endif
@@ -522,11 +554,19 @@ void Z_CheckHeap2(const char *file, INT32 line)
}
if (block->prev->next != block)
{
I_Error("Z_CheckHeap %s %d: block %u"
I_Error("Z_CheckHeap"
#ifdef ZDEBUG
"at %s %d :"
#endif
"block %u"
#ifdef ZDEBUG
"(owned by %s:%d)"
#endif
" lacks proper forward link", file, line, blocknumon
" lacks proper forward link"
#ifdef ZDEBUG
, file, line
#endif
, blocknumon
#ifdef ZDEBUG
, block->ownerfile, block->ownerline
#endif
@@ -534,11 +574,19 @@ void Z_CheckHeap2(const char *file, INT32 line)
}
if (block->id != ZONEID)
{
I_Error("Z_CheckHeap %s %d: block %u"
I_Error("Z_CheckHeap"
#ifdef ZDEBUG
"at %s %d :"
#endif
"block %u"
#ifdef ZDEBUG
"(owned by %s:%d)"
#endif
" have the wrong ID", file, line, blocknumon
" have the wrong ID"
#ifdef ZDEBUG
, file, line
#endif
, blocknumon
#ifdef ZDEBUG
, block->ownerfile, block->ownerline
#endif
+10
View File
@@ -110,9 +110,14 @@ void *Z_ReallocAlign(void *ptr, size_t size, INT32 tag, void *user, INT32 alignb
// Free all memory by tag
// these don't give line numbers for ZDEBUG currently though
// (perhaps this should be changed in future?)
#ifdef ZDEBUG
#define Z_FreeTag(tagnum) Z_FreeTags2(tagnum, tagnum, __FILE__, __LINE__)
#define Z_FreeTags(tagnum, tagnum2) Z_FreeTags2(tagnum, tagnum2, __FILE__, __LINE__)
void Z_FreeTags2(INT32 lowtag, INT32 hightag, const char *file, INT32 line);
#else
#define Z_FreeTag(tagnum) Z_FreeTags(tagnum, tagnum)
void Z_FreeTags(INT32 lowtag, INT32 hightag);
#endif
// Iterate memory by tag
#define Z_IterateTag(tagnum, func) Z_IterateTags(tagnum, tagnum, func)
@@ -122,8 +127,13 @@ void Z_IterateTags(INT32 lowtag, INT32 hightag, boolean (*iterfunc)(void *));
// Utility functions
//
void Z_CheckMemCleanup(void);
#ifdef ZDEBUG
#define Z_CheckHeap(tag) Z_CheckHeap2(__FILE__, __LINE__)
void Z_CheckHeap2(const char *file, INT32 line);
#else
void Z_CheckHeap(INT32 tag);
#endif
//
// Zone memory modification