summaryrefslogtreecommitdiff
path: root/libdm/mm
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2011-10-28 20:37:31 +0000
committerZdenek Kabelac <zkabelac@redhat.com>2011-10-28 20:37:31 +0000
commit8009588314cbe9928f6738567af4ac09c84b8576 (patch)
tree8edecd3017044a0d4e444ce5cbd6eb14d093a111 /libdm/mm
parent070f7171314bc25b9443c1130ef697eafea33b4a (diff)
downloadlvm2-8009588314cbe9928f6738567af4ac09c84b8576.tar.gz
Improve valgrind support when compiled with DEBUG_MEM
Diffstat (limited to 'libdm/mm')
-rw-r--r--libdm/mm/dbg_malloc.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/libdm/mm/dbg_malloc.c b/libdm/mm/dbg_malloc.c
index cf8330cf4..084932a20 100644
--- a/libdm/mm/dbg_malloc.c
+++ b/libdm/mm/dbg_malloc.c
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
*
* This file is part of the device-mapper userspace tools.
*
@@ -15,6 +15,10 @@
#include "dmlib.h"
+#ifdef VALGRIND_POOL
+#include "valgrind/memcheck.h"
+#endif
+
#include <assert.h>
#include <stdarg.h>
@@ -115,7 +119,9 @@ void *dm_malloc_aux_debug(size_t s, const char *file, int line)
/* log_debug("Allocated: %u %u %u", nb->id, _mem_stats.blocks_allocated,
_mem_stats.bytes); */
-
+#ifdef VALGRIND_POOL
+ VALGRIND_MAKE_MEM_UNDEFINED(nb + 1, s);
+#endif
return nb + 1;
}
@@ -141,7 +147,9 @@ void dm_free_aux(void *p)
/* sanity check */
assert(mb->magic == p);
-
+#ifdef VALGRIND_POOL
+ VALGRIND_MAKE_MEM_DEFINED(p, mb->length);
+#endif
/* check data at the far boundary */
ptr = (char *) p + mb->length;
for (i = 0; i < sizeof(unsigned long); i++)