Deleted Added
full compact
strdup.c (33965) strdup.c (89857)
1/*
2
3@deftypefn Supplemental char* strdup (const char *@var{s})
4
5Returns a pointer to a copy of @var{s} in memory obtained from
6@code{malloc}, or @code{NULL} if insufficient memory was available.
7
8@end deftypefn
9
10*/
11
1char *
2strdup(s)
3 char *s;
4{
5 char *result = (char*)malloc(strlen(s) + 1);
6 if (result == (char*)0)
7 return (char*)0;
8 strcpy(result, s);
9 return result;
10}
12char *
13strdup(s)
14 char *s;
15{
16 char *result = (char*)malloc(strlen(s) + 1);
17 if (result == (char*)0)
18 return (char*)0;
19 strcpy(result, s);
20 return result;
21}