]> git.ipfire.org Git - thirdparty/gcc.git/blame - libiberty/xstrdup.c
Update configure deps, remove stray \xA0 in picflag.m4, regenerate
[thirdparty/gcc.git] / libiberty / xstrdup.c
CommitLineData
28e9041c 1/* xstrdup.c -- Duplicate a string in memory, using xmalloc.
2 This trivial function is in the public domain.
3 Ian Lance Taylor, Cygnus Support, December 1995. */
4
614a23c6 5/*
6
7@deftypefn Replacement char* xstrdup (const char *@var{s})
8
9Duplicates a character string without fail, using @code{xmalloc} to
10obtain memory.
11
12@end deftypefn
13
14*/
15
6aa62a59 16#ifdef HAVE_CONFIG_H
17#include "config.h"
18#endif
a11e6147 19#include <sys/types.h>
6aa62a59 20#ifdef HAVE_STRING_H
21#include <string.h>
1cf8f41f 22#else
23# ifdef HAVE_STRINGS_H
24# include <strings.h>
25# endif
6aa62a59 26#endif
28e9041c 27#include "ansidecl.h"
28#include "libiberty.h"
29
30char *
cd72df1f 31xstrdup (const char *s)
28e9041c 32{
6aa62a59 33 register size_t len = strlen (s) + 1;
f2d737fc 34 register char *ret = XNEWVEC (char, len);
1cf8f41f 35 return (char *) memcpy (ret, s, len);
28e9041c 36}