diff --git a/include/QF/progs.h b/include/QF/progs.h index 7567ddc09..95d5db44c 100644 --- a/include/QF/progs.h +++ b/include/QF/progs.h @@ -1614,6 +1614,7 @@ void PR_Zone_Init (progs_t *pr); void PR_Zone_Free (progs_t *pr, void *ptr); void *PR_Zone_Malloc (progs_t *pr, pr_int_t size); void *PR_Zone_Realloc (progs_t *pr, void *ptr, pr_int_t size); +void *PR_Zone_TagMalloc (progs_t *pr, int size, int tag); ///@} diff --git a/libs/gamecode/pr_zone.c b/libs/gamecode/pr_zone.c index e7239bc0c..5b85a7ffd 100644 --- a/libs/gamecode/pr_zone.c +++ b/libs/gamecode/pr_zone.c @@ -49,6 +49,7 @@ static void pr_zone_error (void *_pr, const char *msg) { progs_t *pr = (progs_t *) _pr; + Z_Print (pr->zone); PR_RunError (pr, "%s", msg); } @@ -74,6 +75,14 @@ PR_Zone_Malloc (progs_t *pr, pr_int_t size) return Z_Malloc (pr->zone, size); } +VISIBLE void * +PR_Zone_TagMalloc (progs_t *pr, int size, int tag) +{ + if (size <= 0) + PR_RunError (pr, "attempt to allocate less than 1 byte"); + return Z_TagMalloc (pr->zone, size, tag); +} + VISIBLE void * PR_Zone_Realloc (progs_t *pr, void *ptr, pr_int_t size) { diff --git a/libs/ruamoko/rua_obj.c b/libs/ruamoko/rua_obj.c index 53b4d3e80..91b9e5692 100644 --- a/libs/ruamoko/rua_obj.c +++ b/libs/ruamoko/rua_obj.c @@ -1702,8 +1702,8 @@ class_create_instance (progs_t *pr, pr_class_t *class) pr_type_t *mem; pr_id_t *id; - mem = PR_Zone_Malloc (pr, size); - // redundant memset (id, 0, size); + mem = PR_Zone_TagMalloc (pr, size, class->name); + memset (mem, 0, size); id = (pr_id_t *) (mem + 1); id->class_pointer = PR_SetPointer (pr, class); return id; diff --git a/libs/util/zone.c b/libs/util/zone.c index f5c90a379..40af412ba 100644 --- a/libs/util/zone.c +++ b/libs/util/zone.c @@ -337,7 +337,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:%3i ofs:%x\n", + Sys_Printf ("block:%p size:%7i tag:%5x ofs:%x\n", block, z_block_size (block), block->tag, z_offset (zone, block));