Added all of the MH sources, including RCS files, in
[mmh] / docs / historical / mh-6.8.5 / sbr / getcpy.c
1 /* getcpy.c - copy a string in managed memory */
2
3 #include "../h/mh.h"
4 #include <stdio.h>
5
6
7 char   *getcpy (str)
8 register char  *str;
9 {
10     register char  *cp;
11
12     if (!str) {
13         if ((cp = malloc ((unsigned) (1))) == NULL)
14             adios (NULLCP, "unable to allocate string storage");
15         (void) strcpy (cp, "");
16     } else {
17         if ((cp = malloc ((unsigned) (strlen (str) + 1))) == NULL)
18             adios (NULLCP, "unable to allocate string storage");
19
20         (void) strcpy (cp, str);
21     }
22     return cp;
23 }