From bceb4a7c92cdabff27924db9cb34494e370552a8 Mon Sep 17 00:00:00 2001 From: Gunnar Ritter Date: Tue, 5 Apr 2005 15:08:12 +0000 Subject: [PATCH] valgrind support --- mapmalloc.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/mapmalloc.c b/mapmalloc.c index 017b992..9cb49df 100644 --- a/mapmalloc.c +++ b/mapmalloc.c @@ -36,7 +36,7 @@ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * Sccsid @(#)mapmalloc.c 1.4 (gritter) 2/20/05 + * Sccsid @(#)mapmalloc.c 1.5 (gritter) 4/5/05 */ #ifdef VMUNIX @@ -108,6 +108,13 @@ void dump(const char *msg, uintptr_t t) #define dump(a, b) #endif +#ifdef valgrind +#include +#else /* !valgrind */ +#define VALGRIND_MALLOCLIKE_BLOCK(a, b, c, d) +#define VALGRIND_FREELIKE_BLOCK(a, b) +#endif /* !valgrind */ + /* avoid break bug */ #ifdef pdp11 #define GRANULE 64 @@ -292,6 +299,7 @@ found: p->ptr = setbusy(allocp); p[1].pool = o; dump("malloc", (uintptr_t)(p + 2)); + VALGRIND_MALLOCLIKE_BLOCK(p+2,nbytes,0,0); return(p+2); } @@ -313,6 +321,7 @@ free(register void *ap) ASSERT(testbusy(p->ptr)); p->ptr = clearbusy(p->ptr); ASSERT(p->ptr > allocp && p->ptr <= alloct); + VALGRIND_FREELIKE_BLOCK(ap,0); } /* realloc(p, nbytes) reallocates a block obtained from malloc()