]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
* xstrdup.c (xstrdup): Switch from strcpy to memcpy for speed.
authorKaveh R. Ghazi <ghazi@caip.rutgers.edu>
Wed, 13 Jan 1999 11:30:56 +0000 (11:30 +0000)
committerKaveh Ghazi <ghazi@gcc.gnu.org>
Wed, 13 Jan 1999 11:30:56 +0000 (11:30 +0000)
From-SVN: r24651

libiberty/ChangeLog
libiberty/xstrdup.c

index 63d9ee82ddf02ce606a4261fff4890bb8db1d0b8..b8aea25e4d820422c0e08ef84f4159ce99f5dfa1 100644 (file)
@@ -1,3 +1,7 @@
+Wed Jan 13 14:16:36 1999  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
+
+       * xstrdup.c (xstrdup): Switch from strcpy to memcpy for speed.
+
 Tue Dec 22 09:43:35 1998  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        * argv.c (buildargv): Cast the result of alloca in assignment.
index 9d08bc704055d781ebc9c96b9ceb47e6cfc3012e..e16aba08554b02af84c04f61a464a7f024185bf3 100644 (file)
@@ -2,16 +2,21 @@
    This trivial function is in the public domain.
    Ian Lance Taylor, Cygnus Support, December 1995.  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
 #include "ansidecl.h"
 #include "libiberty.h"
 
 char *
 xstrdup (s)
-     const char *s;
+  const char *s;
 {
-  char *ret;
-
-  ret = xmalloc (strlen (s) + 1);
-  strcpy (ret, s);
+  register size_t len = strlen (s) + 1;
+  register char *ret = xmalloc (len);
+  memcpy (ret, s, len);
   return ret;
 }