OSDN Git Service

* cplus-dem.c (main): Use table lookup to distinguish identifier
[pf3gnuchains/gcc-fork.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 }