]> git.ipfire.org Git - thirdparty/gcc.git/blame - libiberty/xstrdup.c
Fix typo in last checkin.
[thirdparty/gcc.git] / libiberty / xstrdup.c
CommitLineData
6599da04
JM
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
aaa5f039
DD
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
df548dfc 16#include <sys/types.h>
7e4311a3
KG
17#ifdef HAVE_CONFIG_H
18#include "config.h"
19#endif
20#ifdef HAVE_STRING_H
21#include <string.h>
22#endif
6599da04
JM
23#include "ansidecl.h"
24#include "libiberty.h"
25
26char *
27xstrdup (s)
7e4311a3 28 const char *s;
6599da04 29{
7e4311a3
KG
30 register size_t len = strlen (s) + 1;
31 register char *ret = xmalloc (len);
32 memcpy (ret, s, len);
6599da04
JM
33 return ret;
34}