mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-17 01:11:45 +00:00
[zone] Add functions to get and set the tag
Getting the tag is possibly useful in general and definitely in debugging. Setting, I'm not so sure as it should be done when allocated, but that's not always possible. Also, correct the return type of z_block_size, though it affected only Z_Print. While an allocation larger than 4GB is... big for zone, the blocks do support it, so printing should too.
This commit is contained in:
parent
2298227546
commit
11fee8571c
2 changed files with 22 additions and 2 deletions
|
@ -112,6 +112,10 @@ void Z_CheckPointer (const memzone_t *zone, const void *ptr, size_t size);
|
|||
int Z_IncRetainCount (memzone_t *zone, void *ptr);
|
||||
int Z_DecRetainCount (memzone_t *zone, void *ptr);
|
||||
int Z_GetRetainCount (memzone_t *zone, void *ptr) __attribute__((pure));
|
||||
int Z_GetTag (memzone_t *zone, void *ptr) __attribute__((pure));
|
||||
void Z_SetTag (memzone_t *zone, void *ptr, int tag);
|
||||
|
||||
|
||||
|
||||
memhunk_t *Hunk_Init (void *buf, size_t size);
|
||||
void Hunk_Print (memhunk_t *hunk, qboolean all);
|
||||
|
|
|
@ -92,7 +92,7 @@ struct memzone_s {
|
|||
memblock_t blocklist; // start / end cap for linked list
|
||||
} __attribute__((aligned (64)));
|
||||
|
||||
static int
|
||||
static size_t
|
||||
z_block_size (memblock_t *block)
|
||||
{
|
||||
return block->block_size - sizeof (memblock_t) - 4;
|
||||
|
@ -359,7 +359,7 @@ Z_Print (memzone_t *zone)
|
|||
zone->size, zone, zone->used);
|
||||
|
||||
for (block = zone->blocklist.next ; ; block = block->next) {
|
||||
Sys_Printf ("block:%p size:%7i tag:%5x ret: %5d ofs:%x\n",
|
||||
Sys_Printf ("block:%p size:%8zd tag:%5x ret: %5d ofs:%x\n",
|
||||
block, z_block_size (block),
|
||||
block->tag, block->retain, z_offset (zone, block));
|
||||
|
||||
|
@ -468,6 +468,22 @@ Z_GetRetainCount (memzone_t *zone, void *ptr)
|
|||
return block->retain;
|
||||
}
|
||||
|
||||
VISIBLE int
|
||||
Z_GetTag (memzone_t *zone, void *ptr)
|
||||
{
|
||||
memblock_t *block = (memblock_t *) ((byte *) ptr - sizeof (memblock_t));
|
||||
return block->tag;
|
||||
}
|
||||
|
||||
VISIBLE void
|
||||
Z_SetTag (memzone_t *zone, void *ptr, int tag)
|
||||
{
|
||||
if (!tag) {
|
||||
z_error (zone, "Attept to set tag to 0");
|
||||
}
|
||||
memblock_t *block = (memblock_t *) ((byte *) ptr - sizeof (memblock_t));
|
||||
block->tag = tag;
|
||||
}
|
||||
VISIBLE void
|
||||
Z_MemInfo (const memzone_t *zone, size_t *used, size_t *size)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue