Reduce size of memblock_t structure
This commit is contained in:
1 parent
347a5ed40a
commit
ebb0ebcab0
1 file changed
+14
-10
+14
-10
@@ -57,11 +57,12 @@ static boolean Z_calloc = false;
|
||||
typedef struct memblock_s
|
||||
{
|
||||
void **user;
|
||||
INT32 tag; // purgelevel
|
||||
UINT32 id; // Should be ZONEID
|
||||
size_t size; // excluding the block
|
||||
|
||||
size_t size; // including the header and blocks
|
||||
size_t realsize; // size of real data only
|
||||
#ifdef PARANOIA
|
||||
UINT32 id; // Should be ZONEID
|
||||
#endif
|
||||
UINT8 tag; // purgelevel
|
||||
|
||||
#ifdef ZDEBUG
|
||||
const char *ownerfile;
|
||||
@@ -260,14 +261,15 @@ void *Z_Malloc(size_t size, INT32 tag, void *user)
|
||||
block->ownerline = line;
|
||||
block->ownerfile = file;
|
||||
#endif
|
||||
block->size = sizeof (memblock_t) + size;
|
||||
block->realsize = size;
|
||||
block->size = size;
|
||||
|
||||
#ifdef VALGRIND_CREATE_MEMPOOL
|
||||
VALGRIND_CREATE_MEMPOOL(block, size, Z_calloc);
|
||||
#endif
|
||||
|
||||
#ifdef PARANOIA
|
||||
block->id = ZONEID;
|
||||
#endif
|
||||
|
||||
if (user != NULL)
|
||||
{
|
||||
@@ -376,10 +378,10 @@ void *Z_Realloc(void *ptr, size_t size, INT32 tag, void *user)
|
||||
rez = Z_Malloc(size, tag, user);
|
||||
#endif
|
||||
|
||||
if (size < block->realsize)
|
||||
if (size < block->size)
|
||||
copysize = size;
|
||||
else
|
||||
copysize = block->realsize;
|
||||
copysize = block->size;
|
||||
|
||||
M_Memcpy(rez, ptr, copysize);
|
||||
|
||||
@@ -593,6 +595,7 @@ void Z_CheckHeap(INT32 tag)
|
||||
#endif
|
||||
);
|
||||
}
|
||||
#ifdef PARANOIA
|
||||
if (block->id != ZONEID)
|
||||
{
|
||||
I_Error("Z_CheckHeap :"
|
||||
@@ -613,6 +616,7 @@ void Z_CheckHeap(INT32 tag)
|
||||
#endif
|
||||
);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -706,7 +710,7 @@ size_t Z_TagsUsage(INT32 lowtag, INT32 hightag)
|
||||
{
|
||||
if (rover->tag < lowtag || rover->tag > hightag)
|
||||
continue;
|
||||
cnt += rover->size + sizeof *rover;
|
||||
cnt += rover->size + sizeof(memblock_t);
|
||||
}
|
||||
|
||||
return cnt;
|
||||
@@ -781,7 +785,7 @@ static void Command_Memdump_f(void)
|
||||
if (block->tag >= mintag && block->tag <= maxtag)
|
||||
{
|
||||
const char *filename = strrchr(block->ownerfile, PATHSEP[0]);
|
||||
CONS_Printf("[%3d] %s (%s) bytes @ %s:%d\n", block->tag, sizeu1(block->size), sizeu2(block->realsize), filename ? filename + 1 : block->ownerfile, block->ownerline);
|
||||
CONS_Printf("[%3d] %s (%s) bytes @ %s:%d\n", block->tag, sizeu1(block->size + sizeof(memblock_t)), sizeu2(block->size), filename ? filename + 1 : block->ownerfile, block->ownerline);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in new issue
Block a user