From 97ee9c3f29d2708e2a9383c5bfe5a3dd7dfe60dd Mon Sep 17 00:00:00 2001 From: kan Date: Sat, 19 May 2007 01:27:20 +0000 Subject: GCC 4.2.0 release miscellaneous support libraries. --- contrib/gcclibs/libiberty/xstrdup.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 contrib/gcclibs/libiberty/xstrdup.c (limited to 'contrib/gcclibs/libiberty/xstrdup.c') diff --git a/contrib/gcclibs/libiberty/xstrdup.c b/contrib/gcclibs/libiberty/xstrdup.c new file mode 100644 index 0000000..9ac2ea0 --- /dev/null +++ b/contrib/gcclibs/libiberty/xstrdup.c @@ -0,0 +1,36 @@ +/* xstrdup.c -- Duplicate a string in memory, using xmalloc. + 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 +#ifdef HAVE_STRING_H +#include +#else +# ifdef HAVE_STRINGS_H +# include +# endif +#endif +#include "ansidecl.h" +#include "libiberty.h" + +char * +xstrdup (const char *s) +{ + register size_t len = strlen (s) + 1; + register char *ret = XNEWVEC (char, len); + return (char *) memcpy (ret, s, len); +} -- cgit v1.1