]> diplodocus.org Git - nmh/blob - sbr/strdup.c
use fork instead of vfork on Linux
[nmh] / sbr / strdup.c
1
2 /*
3 * strdup.c -- duplicate a string
4 *
5 * $Id$
6 *
7 * This code is Copyright (c) 2002, by the authors of nmh. See the
8 * COPYRIGHT file in the root directory of the nmh distribution for
9 * complete copyright information.
10 */
11
12 #include <h/mh.h>
13
14
15 char *
16 strdup (const char *str)
17 {
18 char *cp;
19 size_t len;
20
21 if (!str)
22 return NULL;
23
24 len = strlen(str) + 1;
25 if (!(cp = malloc (len)))
26 return NULL;
27 memcpy (cp, str, len);
28 return cp;
29 }