[PATCH] Simplify strncat.
Paul Eggert
eggert@cs.ucla.edu
Tue Dec 16 20:50:00 GMT 2014
Thanks, this is much better than worrying about how to pacify GCC. The
code could be made a bit shorter and clearer with mempcpy, and there's
no longer any need to distinguish between s and s1, so I suggest the
following minor rewrite, which shrinks the code size by another 26 bytes
(16%) on my x86-64 platform.
char *
STRNCAT (char *s1, const char *s2, size_t n)
{
char *s1_end = mempcpy (s1 + strlen (s1), s2, __strnlen (s2, n));
*s1_end = '\0';
return s1;
}
More information about the Libc-alpha
mailing list