X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=libiberty%2Fxstrdup.c;h=c04623d98ecfb2be9ea9398b829d08d5b34e1da7;hb=ddb5d39db4331cd049d1e9f35aa7d41a486fb366;hp=342412806da8155ba19ccda5d93a70a50afe7ebe;hpb=f72cbe85b80644fca327c5de8a98144ca430db22;p=pf3gnuchains%2Fgcc-fork.git diff --git a/libiberty/xstrdup.c b/libiberty/xstrdup.c index 342412806da..c04623d98ec 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; + return (char *) memcpy (ret, s, len); }