* Makefile.in (rtlanal.o): Depend on $(TM_P_H).
[official-gcc.git] / libiberty / strdup.c
blob49233ba7aac99603030a43264b5e7ea8b08149d3
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 char *
13 strdup(s)
14 char *s;
16 char *result = (char*)malloc(strlen(s) + 1);
17 if (result == (char*)0)
18 return (char*)0;
19 strcpy(result, s);
20 return result;