From f559d8cf2963868a2493289b17be68f3786c789e Mon Sep 17 00:00:00 2001 From: Richard Earnshaw Date: Tue, 23 Dec 2014 08:57:07 -0800 Subject: * string/stpcpy.c (__stpcpy): Rewrite using strlen and memcpy. --- string/stpcpy.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'string') diff --git a/string/stpcpy.c b/string/stpcpy.c index 9185acc034..fd6eb1c3de 100644 --- a/string/stpcpy.c +++ b/string/stpcpy.c @@ -35,14 +35,8 @@ __stpcpy (dest, src) char *dest; const char *src; { - char *d = dest; - const char *s = src; - - do - *d++ = *s; - while (*s++ != '\0'); - - return d - 1; + size_t len = strlen (src); + return memcpy (dest, src, len + 1) + len; } #ifdef libc_hidden_def libc_hidden_def (__stpcpy) -- cgit 1.4.1