From 04275a672a22e62903a63f64b02d6b4ac97ef383 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Thu, 20 Oct 2011 13:39:57 +0000 Subject: [PATCH] Mark chunk memory for free as defined again for valgrind When DEBUG_MEM is used, the memory is trashed with extra pattern before real free() is called, and as this memory was marked as non accessible when used with valgrind, make it again usable. --- WHATS_NEW_DM | 1 + libdm/mm/pool-fast.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM index 13cc57916..e7c01246c 100644 --- a/WHATS_NEW_DM +++ b/WHATS_NEW_DM @@ -1,5 +1,6 @@ Version 1.02.68 - ================================== + Fix valgrind error reports in free of pool chunks with DEBUG_MEM. Aling size of structure chunk for fast pool allocator to 8 bytes. Simplify some pointer operations in dm_free_aux() debug code. Remove unused dbg_malloc.h file from source tree. diff --git a/libdm/mm/pool-fast.c b/libdm/mm/pool-fast.c index 386776196..e14d073ca 100644 --- a/libdm/mm/pool-fast.c +++ b/libdm/mm/pool-fast.c @@ -300,6 +300,12 @@ static struct chunk *_new_chunk(struct dm_pool *p, size_t s) static void _free_chunk(struct chunk *c) { +#ifdef VALGRIND_POOL +# ifdef DEBUG_MEM + if (c) + VALGRIND_MAKE_MEM_UNDEFINED(c + 1, c->end - (char *) (c + 1)); +# endif +#endif dm_free(c); } -- 2.43.5