X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=libiberty%2Fxstrdup.c;h=fa12c96a3cd61e8f7ca919d3dd3ef74989871e3b;hb=5ecffcbbd49639b83e574a0411f8a3088093f4aa;hp=e16aba08554b02af84c04f61a464a7f024185bf3;hpb=252b5132c753830d5fd56823373aed85f2a0db63;p=platform%2Fupstream%2Fbinutils.git diff --git a/libiberty/xstrdup.c b/libiberty/xstrdup.c index e16aba0..fa12c96 100644 --- a/libiberty/xstrdup.c +++ b/libiberty/xstrdup.c @@ -2,21 +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 + +*/ + #ifdef HAVE_CONFIG_H #include "config.h" #endif +#include #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); }