This commit was generated by cvs2svn to track changes on a CVS vendor
[deliverable/binutils-gdb.git] / libiberty / xstrdup.c
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
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"
13
14 char *
15 xstrdup (s)
16 const char *s;
17 {
18 register size_t len = strlen (s) + 1;
19 register char *ret = xmalloc (len);
20 memcpy (ret, s, len);
21 return ret;
22 }
This page took 0.030858 seconds and 5 git commands to generate.