From: Florian Krohm Date: Thu, 24 Jul 2014 12:50:03 +0000 (+0000) Subject: Change VG_(strncpy_safely) to use VG_(strncpy) to get the same padding X-Git-Tag: svn/VALGRIND_3_10_0~252 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e402f69a09eead8240ee2a67361a734fa72a62c6;p=thirdparty%2Fvalgrind.git Change VG_(strncpy_safely) to use VG_(strncpy) to get the same padding behaviour. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14186 --- diff --git a/coregrind/m_debuginfo/debuginfo.c b/coregrind/m_debuginfo/debuginfo.c index 85d3ca8535..99157b2c2a 100644 --- a/coregrind/m_debuginfo/debuginfo.c +++ b/coregrind/m_debuginfo/debuginfo.c @@ -1870,7 +1870,6 @@ 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 56a7039740..97af7c7c2d 100644 --- a/coregrind/m_libcbase.c +++ b/coregrind/m_libcbase.c @@ -304,14 +304,8 @@ void VG_(strncpy_safely) ( HChar* dest, const HChar* src, SizeT ndest ) { libcbase_assert(ndest > 0); - SizeT i = 0; - while (True) { - dest[i] = 0; - if (src[i] == 0) return; - if (i >= ndest-1) return; - dest[i] = src[i]; - i++; - } + VG_(strncpy)(dest, src, ndest); + dest[ndest - 1] = '\0'; } HChar* VG_(strncpy) ( HChar* dest, const HChar* src, SizeT ndest )