mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-05-31 16:51:08 +00:00
[zone] Move heap check to Z_TagMalloc
Since Z_Malloc uses Z_TagMalloc to do the work, this ensures the check is always run. Also, add the check to Z_Realloc when it needs to adjust an existing block.
This commit is contained in:
parent
b8c2b7f856
commit
2fcec6e5cb
1 changed files with 6 additions and 2 deletions
|
@ -202,8 +202,6 @@ Z_Malloc (memzone_t *zone, size_t size)
|
||||||
{
|
{
|
||||||
void *buf;
|
void *buf;
|
||||||
|
|
||||||
if (!developer || developer->int_val & SYS_dev)
|
|
||||||
Z_CheckHeap (zone); // DEBUG
|
|
||||||
buf = Z_TagMalloc (zone, size, 1);
|
buf = Z_TagMalloc (zone, size, 1);
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
const char *msg;
|
const char *msg;
|
||||||
|
@ -224,6 +222,9 @@ Z_TagMalloc (memzone_t *zone, size_t size, int tag)
|
||||||
int requested_size = size;
|
int requested_size = size;
|
||||||
memblock_t *start, *rover, *new, *base;
|
memblock_t *start, *rover, *new, *base;
|
||||||
|
|
||||||
|
if (!developer || developer->int_val & SYS_dev)
|
||||||
|
Z_CheckHeap (zone); // DEBUG
|
||||||
|
|
||||||
if (!tag) {
|
if (!tag) {
|
||||||
if (zone->error)
|
if (zone->error)
|
||||||
zone->error (zone->data, "Z_TagMalloc: tried to use a 0 tag");
|
zone->error (zone->data, "Z_TagMalloc: tried to use a 0 tag");
|
||||||
|
@ -290,6 +291,9 @@ Z_Realloc (memzone_t *zone, void *ptr, size_t size)
|
||||||
if (!ptr)
|
if (!ptr)
|
||||||
return Z_Malloc (zone, size);
|
return Z_Malloc (zone, size);
|
||||||
|
|
||||||
|
if (!developer || developer->int_val & SYS_dev)
|
||||||
|
Z_CheckHeap (zone); // DEBUG
|
||||||
|
|
||||||
block = (memblock_t *) ((byte *) ptr - sizeof (memblock_t));
|
block = (memblock_t *) ((byte *) ptr - sizeof (memblock_t));
|
||||||
if (block->id != ZONEID/* || block->id2 != ZONEID*/) {
|
if (block->id != ZONEID/* || block->id2 != ZONEID*/) {
|
||||||
if (zone->error)
|
if (zone->error)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue