From 90e7e07d7e851377ed738285f1ef861f6cf3c319 Mon Sep 17 00:00:00 2001 From: Florian Krohm Date: Tue, 29 Jul 2014 08:46:15 +0000 Subject: [PATCH] Back out r14186 as it was identified to have caused a performance regression. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14201 --- coregrind/m_debuginfo/debuginfo.c | 1 + coregrind/m_libcbase.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/coregrind/m_debuginfo/debuginfo.c b/coregrind/m_debuginfo/debuginfo.c index 333b8c57e3..02a2139178 100644 --- a/coregrind/m_debuginfo/debuginfo.c +++ b/coregrind/m_debuginfo/debuginfo.c @@ -1870,6 +1870,7 @@ Bool VG_(get_objname) ( Addr a, HChar* buf, Int nbuf ) && di->text_avma <= a && a < di->text_avma + di->text_size) { VG_(strncpy_safely)(buf, di->fsm.filename, nbuf); + buf[nbuf-1] = 0; return True; } } diff --git a/coregrind/m_libcbase.c b/coregrind/m_libcbase.c index a84eb34aaf..abacd712d6 100644 --- a/coregrind/m_libcbase.c +++ b/coregrind/m_libcbase.c @@ -304,8 +304,14 @@ void VG_(strncpy_safely) ( HChar* dest, const HChar* src, SizeT ndest ) { libcbase_assert(ndest > 0); - VG_(strncpy)(dest, src, ndest); - dest[ndest - 1] = '\0'; + SizeT i = 0; + while (True) { + dest[i] = 0; + if (src[i] == 0) return; + if (i >= ndest-1) return; + dest[i] = src[i]; + i++; + } } HChar* VG_(strncpy) ( HChar* dest, const HChar* src, SizeT ndest ) -- 2.47.2