19990502 sourceware import
[deliverable/binutils-gdb.git] / libiberty / xstrdup.c
CommitLineData
252b5132
RH
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
14char *
15xstrdup (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.025206 seconds and 4 git commands to generate.