* elf32-arm.c (elf32_arm_modify_segment_map): New function.
[binutils.git] / libiberty / strdup.c
bloba3f17d3bcb1e6f63da5885718b16c18fc091eac6
1 /*
3 @deftypefn Supplemental char* strdup (const char *@var{s})
5 Returns a pointer to a copy of @var{s} in memory obtained from
6 @code{malloc}, or @code{NULL} if insufficient memory was available.
8 @end deftypefn
12 #include <ansidecl.h>
13 #ifdef ANSI_PROTOTYPES
14 #include <stddef.h>
15 #else
16 #define size_t unsigned long
17 #endif
19 extern size_t strlen PARAMS ((const char*));
20 extern PTR malloc PARAMS ((size_t));
21 extern PTR memcpy PARAMS ((PTR, const PTR, size_t));
23 char *
24 strdup(s)
25 const char *s;
27 size_t len = strlen (s) + 1;
28 char *result = (char*) malloc (len);
29 if (result == (char*) 0)
30 return (char*) 0;
31 return (char*) memcpy (result, s, len);