diff options
| author | David E. O'Brien <obrien@FreeBSD.org> | 2000-05-12 23:15:20 +0000 |
|---|---|---|
| committer | David E. O'Brien <obrien@FreeBSD.org> | 2000-05-12 23:15:20 +0000 |
| commit | 78ce21c1dfcbe7807f37679871930161a4431ea9 (patch) | |
| tree | 9d4ce42d357c391a11d77254b770908c02ecf672 /contrib/binutils/libiberty/xstrdup.c | |
| parent | 4a6dfd6c0adbe41f5abde95c957a415f8b6eb3dd (diff) | |
Notes
Diffstat (limited to 'contrib/binutils/libiberty/xstrdup.c')
| -rw-r--r-- | contrib/binutils/libiberty/xstrdup.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/contrib/binutils/libiberty/xstrdup.c b/contrib/binutils/libiberty/xstrdup.c index 9d08bc704055d..6f846cfea1568 100644 --- a/contrib/binutils/libiberty/xstrdup.c +++ b/contrib/binutils/libiberty/xstrdup.c @@ -2,16 +2,22 @@ This trivial function is in the public domain. Ian Lance Taylor, Cygnus Support, December 1995. */ +#include <sys/types.h> +#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; } |
