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