From 52ae14f4f4f788947c3b5ec3b7b2892b50499690 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 25 Nov 2009 14:17:39 -0800 Subject: More valgrind integration. Vector objects keep displaced pointers to vector data; they point to element 0 which is actually the third element of the vector. If an object is only referenced by interior pointers, Valgrind reports it as possibly leaked. This change conditionally adds a pointer to the true start of the vector, if Valgrind support is enabled. --- lib.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib.c') diff --git a/lib.c b/lib.c index 66622407..ba484ed7 100644 --- a/lib.c +++ b/lib.c @@ -1378,6 +1378,9 @@ val vector(val alloc) val *v = (val *) chk_malloc(alloc_plus * sizeof *v); vec->v.type = VEC; vec->v.vec = v + 2; +#ifdef HAVE_VALGRIND + vec->v.vec_true_start = v; +#endif v[0] = alloc; v[1] = zero; return vec; @@ -1406,6 +1409,9 @@ val vec_set_fill(val vec, val fill) (new_alloc + 2)*sizeof *newvec); vec->v.vec = newvec + 2; vec->v.vec[vec_alloc] = num(new_alloc); +#ifdef HAVE_VALGRIND + vec->v.vec_true_start = newvec; +#endif } if (fill_delta > 0) { -- cgit v1.2.3