From 28daf265bc651f44dd1c157e901bd1edc205b3b0 Mon Sep 17 00:00:00 2001 From: Arne Goedeke <el@laramies.com> Date: Thu, 10 Oct 2013 16:54:16 +0200 Subject: [PATCH] block_allocator: fixed --with-debug --- src/block_allocator.c | 10 +++++++--- src/las.c | 8 ++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/block_allocator.c b/src/block_allocator.c index 16700e6024..44ac0a5c51 100644 --- a/src/block_allocator.c +++ b/src/block_allocator.c @@ -535,6 +535,10 @@ void ba_walk(struct block_allocator * a, ba_walk_callback cb, void * data) { while(1) { if (free_block == NULL) { it.end = ((char*)BA_LASTBLOCK(it.l, p) + it.l.block_size); +#ifdef PIKE_DEBUG + if ((char*)it.end < (char*)it.cur) + Pike_fatal("Free list not sorted in ba_walk.\n"); +#endif if ((char*)it.end != (char*)it.cur) { cb(&it, data); } @@ -545,12 +549,12 @@ void ba_walk(struct block_allocator * a, ba_walk_callback cb, void * data) { } it.end = free_block; + free_block = free_block->next; + #ifdef PIKE_DEBUG - if (free_block >= free_block->next) + if ((char*)it.end < (char*)it.cur) Pike_fatal("Free list not sorted in ba_walk.\n"); #endif - free_block = free_block->next; - if ((char*)it.end != (char*)it.cur) cb(&it, data); diff --git a/src/las.c b/src/las.c index 4d3b1b1737..104aa88a27 100644 --- a/src/las.c +++ b/src/las.c @@ -534,8 +534,12 @@ void free_all_nodes(void) #endif ba_walk(&Pike_compiler->node_allocator, &node_walker, NULL); #ifdef PIKE_DEBUG - if(!cumulative_parse_error) - Pike_fatal("Failed to free %"PRINTSIZET"d nodes when compiling!\n",e); + if(!cumulative_parse_error) { + size_t n, s; + ba_count_all(&Pike_compiler->node_allocator, &n, &s); + if (n) + Pike_fatal("Failed to free %"PRINTSIZET"d nodes when compiling!\n",n); + } #else } #endif -- GitLab