summaryrefslogtreecommitdiff
path: root/libcpp/lex.c
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2013-02-28 09:58:47 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2013-02-28 09:58:47 +0000
commit61ed1f10c1953a1f235ec02d8795eb6ac2b9f71c (patch)
tree02e8deb1f6a0854b3d5c12df42f42b182142adcf /libcpp/lex.c
parent3e88585b58d32cadbea3d6f9b6eb00cde3ef59fa (diff)
downloadgcc-61ed1f10c1953a1f235ec02d8795eb6ac2b9f71c.tar.gz
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@196333 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libcpp/lex.c')
-rw-r--r--libcpp/lex.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/libcpp/lex.c b/libcpp/lex.c
index 976d9e8b0eb..570c00733cb 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
}
}