Revision 12455,
642 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.
|
Rev | Line | |
---|
[12454] | 1 | |
---|
| 2 | /* |
---|
| 3 | * getcpy.c -- copy a string in managed memory |
---|
| 4 | * |
---|
| 5 | * THIS IS OBSOLETE. NEED TO REPLACE ALL OCCURENCES |
---|
| 6 | * OF GETCPY WITH STRDUP. BUT THIS WILL REQUIRE |
---|
| 7 | * CHANGING PARTS OF THE CODE TO DEAL WITH NULL VALUES. |
---|
| 8 | * |
---|
| 9 | * $Id: getcpy.c,v 1.1.1.1 1999-02-07 18:14:08 danw Exp $ |
---|
| 10 | */ |
---|
| 11 | |
---|
| 12 | #include <h/mh.h> |
---|
| 13 | |
---|
| 14 | |
---|
| 15 | char * |
---|
| 16 | getcpy (char *str) |
---|
| 17 | { |
---|
| 18 | char *cp; |
---|
| 19 | size_t len; |
---|
| 20 | |
---|
| 21 | if (str) { |
---|
| 22 | len = strlen(str) + 1; |
---|
| 23 | if (!(cp = malloc (len))) |
---|
| 24 | adios (NULL, "unable to allocate string storage"); |
---|
| 25 | memcpy (cp, str, len); |
---|
| 26 | } else { |
---|
| 27 | if (!(cp = malloc ((size_t) 1))) |
---|
| 28 | adios (NULL, "unable to allocate string storage"); |
---|
| 29 | *cp = '\0'; |
---|
| 30 | } |
---|
| 31 | return cp; |
---|
| 32 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.