mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 09:11:48 +00:00
Z_Zone: fixup Valgrind support
This commit is contained in:
parent
700d9426d4
commit
15c263e9c7
1 changed files with 11 additions and 8 deletions
19
src/z_zone.c
19
src/z_zone.c
|
@ -232,12 +232,12 @@ void Z_Free(void *ptr)
|
|||
|
||||
// Free the memory and get rid of the block.
|
||||
free(block->real);
|
||||
block->prev->next = block->next;
|
||||
block->next->prev = block->prev;
|
||||
free(block);
|
||||
#ifdef VALGRIND_DESTROY_MEMPOOL
|
||||
VALGRIND_DESTROY_MEMPOOL(block);
|
||||
#endif
|
||||
block->prev->next = block->next;
|
||||
block->next->prev = block->prev;
|
||||
free(block);
|
||||
}
|
||||
|
||||
/** malloc() that doesn't accept failure.
|
||||
|
@ -317,13 +317,9 @@ void *Z_MallocAlign(size_t size, INT32 tag, void *user, INT32 alignbits)
|
|||
// The mem header lives 'sizeof (memhdr_t)' bytes before given.
|
||||
hdr = (memhdr_t *)((UINT8 *)given - sizeof *hdr);
|
||||
|
||||
#ifdef VALGRIND_CREATE_MEMPOOL
|
||||
VALGRIND_CREATE_MEMPOOL(block, padsize, Z_calloc);
|
||||
#ifdef HAVE_VALGRIND
|
||||
Z_calloc = false;
|
||||
#endif
|
||||
#ifdef VALGRIND_MEMPOOL_ALLOC
|
||||
VALGRIND_MEMPOOL_ALLOC(block, hdr, size + sizeof *hdr);
|
||||
#endif
|
||||
|
||||
block->next = head.next;
|
||||
block->prev = &head;
|
||||
|
@ -341,6 +337,13 @@ void *Z_MallocAlign(size_t size, INT32 tag, void *user, INT32 alignbits)
|
|||
block->size = blocksize;
|
||||
block->realsize = size;
|
||||
|
||||
#ifdef VALGRIND_CREATE_MEMPOOL
|
||||
VALGRIND_CREATE_MEMPOOL(block, padsize, Z_calloc);
|
||||
#endif
|
||||
//#ifdef VALGRIND_MEMPOOL_ALLOC
|
||||
// VALGRIND_MEMPOOL_ALLOC(block, hdr, size + sizeof *hdr);
|
||||
//#endif
|
||||
|
||||
hdr->id = ZONEID;
|
||||
hdr->block = block;
|
||||
|
||||
|
|
Loading…
Reference in a new issue