]> diplodocus.org Git - nmh/blob - sbr/getcpy.c
show: remove unreachable code
[nmh] / sbr / getcpy.c
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 * This code is Copyright (c) 2002, by the authors of nmh. See the
10 * COPYRIGHT file in the root directory of the nmh distribution for
11 * complete copyright information.
12 */
13
14 #include <h/mh.h>
15 #include <h/utils.h>
16
17
18 char *
19 getcpy (char *str)
20 {
21 char *cp;
22 size_t len;
23
24 if (str) {
25 len = strlen(str) + 1;
26 cp = mh_xmalloc (len);
27 memcpy (cp, str, len);
28 } else {
29 cp = mh_xmalloc ((size_t) 1);
30 *cp = '\0';
31 }
32 return cp;
33 }