Modularised the malloc/free stuff into two modules: m_mallocfree for the
malloc/free implementation, and m_replacemalloc with the stuff for the tools
that replace malloc with their own version. Previously these two areas of
functionality were mixed up somewhat.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3648 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/memcheck/Makefile.am b/memcheck/Makefile.am
index 6deade3..7c710a0 100644
--- a/memcheck/Makefile.am
+++ b/memcheck/Makefile.am
@@ -7,10 +7,11 @@
vgpreload_memcheck_so_SOURCES = \
mac_replace_strmem.c
-vgpreload_memcheck_so_DEPENDENCIES = $(top_builddir)/coregrind/lib_replace_malloc.a
+vgpreload_memcheck_so_DEPENDENCIES = \
+ $(LIBREPLACEMALLOC)
vgpreload_memcheck_so_LDFLAGS = -shared -Wl,-z,interpose,-z,initfirst \
-Wl,--whole-archive \
- $(top_builddir)/coregrind/lib_replace_malloc.a \
+ $(LIBREPLACEMALLOC) \
-Wl,--no-whole-archive
vgtool_memcheck_so_SOURCES = \
diff --git a/memcheck/mac_shared.c b/memcheck/mac_shared.c
index 55a2bec..9594474 100644
--- a/memcheck/mac_shared.c
+++ b/memcheck/mac_shared.c
@@ -379,7 +379,8 @@
{
Addr a = *(Addr *)ap;
- return VG_(addr_is_in_block)( a, mc->data, mc->size );
+ return VG_(addr_is_in_block)( a, mc->data, mc->size,
+ MAC_MALLOC_REDZONE_SZB );
}
/* Callback for searching malloc'd lists */
diff --git a/memcheck/mac_shared.h b/memcheck/mac_shared.h
index c541fc9..82303e8 100644
--- a/memcheck/mac_shared.h
+++ b/memcheck/mac_shared.h
@@ -37,6 +37,8 @@
#define __MAC_SHARED_H
#include "tool.h"
+#include "pub_tool_mallocfree.h"
+#include "pub_tool_replacemalloc.h"
#define MAC_(str) VGAPPEND(vgMAC_,str)
diff --git a/memcheck/mc_main.c b/memcheck/mc_main.c
index 547c5a9..e169250 100644
--- a/memcheck/mc_main.c
+++ b/memcheck/mc_main.c
@@ -2156,7 +2156,7 @@
MAC_Chunk *m = (MAC_Chunk*)sh_ch;
Addr a = *(Addr*)ap;
- return VG_(addr_is_in_block)(a, m->data, m->size);
+ return VG_(addr_is_in_block)(a, m->data, m->size, MAC_MALLOC_REDZONE_SZB);
}
static Bool client_perm_maybe_describe( Addr a, AddrInfo* ai )
@@ -2168,7 +2168,8 @@
for (i = 0; i < cgb_used; i++) {
if (cgbs[i].start == 0 && cgbs[i].size == 0)
continue;
- if (VG_(addr_is_in_block)(a, cgbs[i].start, cgbs[i].size)) {
+ // Use zero as the redzone for client blocks.
+ if (VG_(addr_is_in_block)(a, cgbs[i].start, cgbs[i].size, 0)) {
MAC_Mempool **d, *mp;
/* OK - maybe it's a mempool, too? */