From d6a93541b62baa9c1115aeac21a68ec6db83a427 Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Fri, 18 Aug 2006 21:38:58 +0000 Subject: reorder bounds check code --- libdm/mm/dbg_malloc.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'libdm/mm') diff --git a/libdm/mm/dbg_malloc.c b/libdm/mm/dbg_malloc.c index 34864444..48fd43dc 100644 --- a/libdm/mm/dbg_malloc.c +++ b/libdm/mm/dbg_malloc.c @@ -77,15 +77,6 @@ void *dm_malloc_aux_debug(size_t s, const char *file, int line) nb->length = s; nb->id = ++_mem_stats.block_serialno; nb->next = 0; - nb->prev = _tail; - - /* link to tail of the list */ - if (!_head) - _head = _tail = nb; - else { - _tail->next = nb; - _tail = nb; - } /* stomp a pretty pattern across the new memory and fill in the boundary bytes */ @@ -99,6 +90,16 @@ void *dm_malloc_aux_debug(size_t s, const char *file, int line) *ptr++ = (char) nb->id; } + nb->prev = _tail; + + /* link to tail of the list */ + if (!_head) + _head = _tail = nb; + else { + _tail->next = nb; + _tail = nb; + } + _mem_stats.blocks_allocated++; if (_mem_stats.blocks_allocated > _mem_stats.blocks_max) _mem_stats.blocks_max = _mem_stats.blocks_allocated; -- cgit