X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=libiberty%2Fxstrdup.c;h=9ac2ea038f344e3b74b548b29cb49a4013262cc7;hb=a857a7d4c5ac75a4bd7a74f6d15d1a72dffc2b5d;hp=342412806da8155ba19ccda5d93a70a50afe7ebe;hpb=f72cbe85b80644fca327c5de8a98144ca430db22;p=pf3gnuchains%2Fgcc-fork.git diff --git a/libiberty/xstrdup.c b/libiberty/xstrdup.c index 342412806da..9ac2ea038f3 100644 --- a/libiberty/xstrdup.c +++ b/libiberty/xstrdup.c @@ -2,22 +2,35 @@ This trivial function is in the public domain. Ian Lance Taylor, Cygnus Support, December 1995. */ +/* + +@deftypefn Replacement char* xstrdup (const char *@var{s}) + +Duplicates a character string without fail, using @code{xmalloc} to +obtain memory. + +@end deftypefn + +*/ + +#include #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include /* For `size_t' */ #ifdef HAVE_STRING_H #include +#else +# ifdef HAVE_STRINGS_H +# include +# endif #endif #include "ansidecl.h" #include "libiberty.h" char * -xstrdup (s) - const char *s; +xstrdup (const char *s) { register size_t len = strlen (s) + 1; - register char *ret = xmalloc (len); - memcpy (ret, s, len); - return ret; + register char *ret = XNEWVEC (char, len); + return (char *) memcpy (ret, s, len); }