From: Kaveh R. Ghazi Date: Wed, 13 Jan 1999 11:30:56 +0000 (+0000) Subject: * xstrdup.c (xstrdup): Switch from strcpy to memcpy for speed. X-Git-Tag: prereleases/libgcj-0.1~1366 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7e4311a31b379a90fbdcdc5f71ed9b27aac29aea;p=thirdparty%2Fgcc.git * xstrdup.c (xstrdup): Switch from strcpy to memcpy for speed. From-SVN: r24651 --- diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index 63d9ee82ddf0..b8aea25e4d82 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,3 +1,7 @@ +Wed Jan 13 14:16:36 1999 Kaveh R. Ghazi + + * xstrdup.c (xstrdup): Switch from strcpy to memcpy for speed. + Tue Dec 22 09:43:35 1998 Kaveh R. Ghazi * argv.c (buildargv): Cast the result of alloca in assignment. diff --git a/libiberty/xstrdup.c b/libiberty/xstrdup.c index 9d08bc704055..e16aba08554b 100644 --- a/libiberty/xstrdup.c +++ b/libiberty/xstrdup.c @@ -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 +#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; }