diff options
author | ghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4> | 1999-01-13 11:30:56 +0000 |
---|---|---|
committer | ghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4> | 1999-01-13 11:30:56 +0000 |
commit | 6aa62a59a07f54bb7cdcc867340d04dd2a9d5f18 (patch) | |
tree | 5889dd61ec05d54493fa16c2d0c09a09abf21a05 /libiberty/xstrdup.c | |
parent | c96e0786393d54b2690336368947958213d20c1f (diff) | |
download | gcc-6aa62a59a07f54bb7cdcc867340d04dd2a9d5f18.tar.gz |
* xstrdup.c (xstrdup): Switch from strcpy to memcpy for speed.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@24651 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libiberty/xstrdup.c')
-rw-r--r-- | libiberty/xstrdup.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/libiberty/xstrdup.c b/libiberty/xstrdup.c index 9d08bc70405..e16aba08554 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; } |