+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.
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;
}