summary refs log tree commit diff
path: root/string/stpcpy.c
diff options
context:
space:
mode:
authorRichard Earnshaw <rearnsha@arm.com>2014-12-23 08:57:07 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2014-12-23 08:58:18 -0800
commitf559d8cf2963868a2493289b17be68f3786c789e (patch)
treef3e0eb81c1de04ec71185dcdce82c57fa255605b /string/stpcpy.c
parent7d81e8d6db95c112c297930a8f2f9617c305529a (diff)
downloadglibc-f559d8cf2963868a2493289b17be68f3786c789e.tar.gz
glibc-f559d8cf2963868a2493289b17be68f3786c789e.tar.xz
glibc-f559d8cf2963868a2493289b17be68f3786c789e.zip
* string/stpcpy.c (__stpcpy): Rewrite using strlen and memcpy.
Diffstat (limited to 'string/stpcpy.c')
-rw-r--r--string/stpcpy.c10
1 files changed, 2 insertions, 8 deletions
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)