* Makefile.in: Change distribution targets to use bzip2 instead of
[binutils.git] / libiberty / xstrdup.c
blobe16aba08554b02af84c04f61a464a7f024185bf3
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. */
5 #ifdef HAVE_CONFIG_H
6 #include "config.h"
7 #endif
8 #ifdef HAVE_STRING_H
9 #include <string.h>
10 #endif
11 #include "ansidecl.h"
12 #include "libiberty.h"
14 char *
15 xstrdup (s)
16 const char *s;
18 register size_t len = strlen (s) + 1;
19 register char *ret = xmalloc (len);
20 memcpy (ret, s, len);
21 return ret;