069784cc7b
version 2.12.0. These bits are taken from the FSF anoncvs repo on 27-January-2002 03:41 PST.
22 lines
388 B
C
22 lines
388 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 @code{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;
|
|
}
|