gdb: add target_ops::supports_displaced_step
[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
39423523
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
252b5132
RH
16#ifdef HAVE_CONFIG_H
17#include "config.h"
18#endif
de8a05ff 19#include <sys/types.h>
252b5132
RH
20#ifdef HAVE_STRING_H
21#include <string.h>
51e32d64
DD
22#else
23# ifdef HAVE_STRINGS_H
24# include <strings.h>
25# endif
252b5132
RH
26#endif
27#include "ansidecl.h"
28#include "libiberty.h"
29
30char *
49b1fae4 31xstrdup (const char *s)
252b5132
RH
32{
33 register size_t len = strlen (s) + 1;
abf6a75b 34 register char *ret = XNEWVEC (char, len);
51e32d64 35 return (char *) memcpy (ret, s, len);
252b5132 36}
This page took 0.831646 seconds and 4 git commands to generate.