diff options
author | Kaveh R. Ghazi <ghazi@caip.rutgers.edu> | 1999-01-13 11:30:56 +0000 |
---|---|---|
committer | Kaveh Ghazi <ghazi@gcc.gnu.org> | 1999-01-13 11:30:56 +0000 |
commit | 7e4311a31b379a90fbdcdc5f71ed9b27aac29aea (patch) | |
tree | 5889dd61ec05d54493fa16c2d0c09a09abf21a05 /libiberty | |
parent | efd59a3308bc1ad7dd1527d9e6fa1feaa0a87f56 (diff) | |
download | gcc-7e4311a31b379a90fbdcdc5f71ed9b27aac29aea.zip gcc-7e4311a31b379a90fbdcdc5f71ed9b27aac29aea.tar.gz gcc-7e4311a31b379a90fbdcdc5f71ed9b27aac29aea.tar.bz2 |
* xstrdup.c (xstrdup): Switch from strcpy to memcpy for speed.
From-SVN: r24651
Diffstat (limited to 'libiberty')
-rw-r--r-- | libiberty/ChangeLog | 4 | ||||
-rw-r--r-- | libiberty/xstrdup.c | 15 |
2 files changed, 14 insertions, 5 deletions
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index 63d9ee8..b8aea25 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -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. diff --git a/libiberty/xstrdup.c b/libiberty/xstrdup.c index 9d08bc7..e16aba0 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 <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; } |