]> diplodocus.org Git - nmh/blob - sbr/strdup.c
Just reworded the bit about '%s' being safe not to quote (it's only safe not to
[nmh] / sbr / strdup.c
1
2 /*
3 * strdup.c -- duplicate a string
4 *
5 * $Id$
6 */
7
8 #include <h/mh.h>
9
10
11 char *
12 strdup (const 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 }