OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gdb/] [gdb-6.8/] [libiberty/] [xstrdup.c] - Blame information for rev 26

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 26 jlechner
/* 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
/*
6
 
7
@deftypefn Replacement char* xstrdup (const char *@var{s})
8
 
9
Duplicates a character string without fail, using @code{xmalloc} to
10
obtain memory.
11
 
12
@end deftypefn
13
 
14
*/
15
 
16
#include <sys/types.h>
17
#ifdef HAVE_CONFIG_H
18
#include "config.h"
19
#endif
20
#ifdef HAVE_STRING_H
21
#include <string.h>
22
#else
23
# ifdef HAVE_STRINGS_H
24
#  include <strings.h>
25
# endif
26
#endif
27
#include "ansidecl.h"
28
#include "libiberty.h"
29
 
30
char *
31
xstrdup (const char *s)
32
{
33
  register size_t len = strlen (s) + 1;
34
  register char *ret = XNEWVEC (char, len);
35
  return (char *) memcpy (ret, s, len);
36
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.