Revision 12455,
327 bytes
checked in by danw, 26 years ago
(diff) |
This commit was generated by cvs2svn to compensate for changes in r12454,
which included commits to RCS files with non-trunk default branches.
|
Line | |
---|
1 | |
---|
2 | /* |
---|
3 | * strdup.c -- duplicate a string |
---|
4 | * |
---|
5 | * $Id: strdup.c,v 1.1.1.1 1999-02-07 18:14:10 danw Exp $ |
---|
6 | */ |
---|
7 | |
---|
8 | #include <h/mh.h> |
---|
9 | |
---|
10 | |
---|
11 | char * |
---|
12 | strdup (char *str) |
---|
13 | { |
---|
14 | char *cp; |
---|
15 | size_t len; |
---|
16 | |
---|
17 | if (!str) |
---|
18 | return NULL; |
---|
19 | |
---|
20 | len = strlen(str) + 1; |
---|
21 | if (!(cp = malloc (len))) |
---|
22 | return NULL; |
---|
23 | memcpy (cp, str, len); |
---|
24 | return cp; |
---|
25 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.