From 1a80db971def22067b3ccbb27b995cd5b86488c0 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 28 Feb 2013 10:58:47 +0100 Subject: configure.ac: Don't define ENABLE_CHECKING whenever --enable-checking is seen... * configure.ac: Don't define ENABLE_CHECKING whenever --enable-checking is seen, instead use similar --enable-checking=yes vs. --enable-checking=release default as gcc/ subdir has and define ENABLE_CHECKING if ENABLE_CHECKING is defined in gcc/. Define ENABLE_VALGRIND_CHECKING if requested. * lex.c (new_buff): If ENABLE_VALGRIND_CHECKING, put _cpp_buff struct first in the allocated buffer and result->base after it. (_cpp_free_buff): If ENABLE_VALGRIND_CHECKING, free buff itself instead of buff->base. * config.in: Regenerated. * configure: Regenerated. From-SVN: r196333 --- libcpp/lex.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'libcpp/lex.c') diff --git a/libcpp/lex.c b/libcpp/lex.c index 976d9e8..570c007 100644 --- a/libcpp/lex.c +++ b/libcpp/lex.c @@ -2846,8 +2846,17 @@ new_buff (size_t len) len = MIN_BUFF_SIZE; len = CPP_ALIGN (len); +#ifdef ENABLE_VALGRIND_CHECKING + /* Valgrind warns about uses of interior pointers, so put _cpp_buff + struct first. */ + size_t slen = CPP_ALIGN2 (sizeof (_cpp_buff), 2 * DEFAULT_ALIGNMENT); + base = XNEWVEC (unsigned char, len + slen); + result = (_cpp_buff *) base; + base += slen; +#else base = XNEWVEC (unsigned char, len + sizeof (_cpp_buff)); result = (_cpp_buff *) (base + len); +#endif result->base = base; result->cur = base; result->limit = base + len; @@ -2934,7 +2943,11 @@ _cpp_free_buff (_cpp_buff *buff) for (; buff; buff = next) { next = buff->next; +#ifdef ENABLE_VALGRIND_CHECKING + free (buff); +#else free (buff->base); +#endif } } -- cgit v1.1