blob: a01cedfbee03359de1dda64646283dba5f7f0acc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
/*
@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;
}
|