|
Last change
on this file since 577 was 10, checked in by bird, 23 years ago |
|
Initial revision
|
-
Property cvs2svn:cvs-rev
set to
1.1
-
Property svn:eol-style
set to
native
-
Property svn:executable
set to
*
|
|
File size:
489 bytes
|
| Line | |
|---|
| 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 | #include <sys/types.h>
|
|---|
| 6 | #ifdef HAVE_CONFIG_H
|
|---|
| 7 | #include "config.h"
|
|---|
| 8 | #endif
|
|---|
| 9 | #ifdef HAVE_STRING_H
|
|---|
| 10 | #include <string.h>
|
|---|
| 11 | #endif
|
|---|
| 12 | #include "ansidecl.h"
|
|---|
| 13 | #include "libiberty.h"
|
|---|
| 14 |
|
|---|
| 15 | char *
|
|---|
| 16 | xstrdup (s)
|
|---|
| 17 | const char *s;
|
|---|
| 18 | {
|
|---|
| 19 | register size_t len = strlen (s) + 1;
|
|---|
| 20 | register char *ret = xmalloc (len);
|
|---|
| 21 | memcpy (ret, s, len);
|
|---|
| 22 | return ret;
|
|---|
| 23 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.