binutils-gdb/libiberty/strdup.c
2001-09-26 18:45:50 +00:00

22 lines
381 B
C

/*
@deftypefn Supplemental char* strdup (const char *@var{s})
Returns a pointer to a copy of @var{s} in memory obtained from
@code{malloc}, or NULL if insufficient memory was available.
@end deftypefn
*/
char *
strdup(s)
char *s;
{
char *result = (char*)malloc(strlen(s) + 1);
if (result == (char*)0)
return (char*)0;
strcpy(result, s);
return result;
}