Merge branch 'Saturn-Next' into Saturn-Testing

This commit is contained in:
Alug committed 2025-07-22 17:35:21 +02:00
commit a61b028e97
2 files changed
+77 -12

No files matched your search

+63 -10
View File
@@ -149,9 +149,12 @@ void Z_Free(void *ptr)
#endif
#endif
#ifdef ZDEBUG
#ifdef ZDEBUG2
// Write every Z_Free call to a debug file.
CONS_Debug(DBG_MEMORY, "Z_Free at %s:%d\n", file, line);
#elif defined(ZDEBUG)
(void)file;
(void)line;
#endif
// anything that isn't by lua gets passed to lua just in case.
@@ -353,8 +356,10 @@ void *Z_Realloc(void *ptr, size_t size, INT32 tag, void *user)
return NULL;
#ifdef ZDEBUG
#ifdef ZDEBUG2
// Write every Z_Realloc call to a debug file.
DEBFILE(va("Z_Realloc at %s:%d\n", file, line));
#endif
rez = Z_Malloc2(size, tag, user, file, line);
#else
rez = Z_Malloc(size, tag, user);
@@ -389,11 +394,19 @@ void *Z_Realloc(void *ptr, size_t size, INT32 tag, void *user)
* \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
@@ -463,12 +476,20 @@ void Z_CheckMemCleanup(void)
* \param i Identifies from where in the code Z_CheckHeap was called.
* \author Graue <graue@oceanbase.org>
*/
void Z_CheckHeap(INT32 i)
#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++;
@@ -493,11 +514,19 @@ void Z_CheckHeap(INT32 i)
#endif
if (block->user != NULL && *(block->user) != given)
{
I_Error("Z_CheckHeap %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", i, blocknumon
" doesn't have a proper user"
#ifdef ZDEBUG
, file, line
#endif
, blocknumon
#ifdef ZDEBUG
, block->ownerfile, block->ownerline
#endif
@@ -505,11 +534,19 @@ void Z_CheckHeap(INT32 i)
}
if (block->next->prev != block)
{
I_Error("Z_CheckHeap %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", i, blocknumon
" lacks proper backlink"
#ifdef ZDEBUG
, file, line
#endif
, blocknumon
#ifdef ZDEBUG
, block->ownerfile, block->ownerline
#endif
@@ -517,11 +554,19 @@ void Z_CheckHeap(INT32 i)
}
if (block->prev->next != block)
{
I_Error("Z_CheckHeap %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", i, blocknumon
" lacks proper forward link"
#ifdef ZDEBUG
, file, line
#endif
, blocknumon
#ifdef ZDEBUG
, block->ownerfile, block->ownerline
#endif
@@ -529,11 +574,19 @@ void Z_CheckHeap(INT32 i)
}
if (block->id != ZONEID)
{
I_Error("Z_CheckHeap %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", i, blocknumon
" have the wrong ID"
#ifdef ZDEBUG
, file, line
#endif
, blocknumon
#ifdef ZDEBUG
, block->ownerfile, block->ownerline
#endif
+14 -2
View File
@@ -32,7 +32,7 @@ extern "C" {
#define FUNCALLOC(x)
#endif
//#define ZDEBUG
#define ZDEBUG
//
// Purge tags
@@ -109,8 +109,14 @@ void *Z_Realloc(void *ptr, size_t size, INT32 tag, void *user) FUNCALLOC(2);
// 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)
@@ -120,7 +126,13 @@ void Z_IterateTags(INT32 lowtag, INT32 hightag, boolean (*iterfunc)(void *));
// Utility functions
//
void Z_CheckMemCleanup(void);
void Z_CheckHeap(INT32 i);
#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