]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/ntp/libntp/strdup.c
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / contrib / ntp / libntp / strdup.c
1 #include <config.h>
2
3 #include <ntp_assert.h>
4 #include "ntp_malloc.h"
5 #include <string.h>
6
7 #ifndef HAVE_STRDUP
8
9 char *strdup(const char *s);
10
11 char *
12 strdup(
13         const char *s
14         )
15 {
16         size_t  octets;
17         char *  cp;
18
19         REQUIRE(s);
20         octets = strlen(s) + 1;
21         if ((cp = malloc(octets)) == NULL)
22                 return NULL;
23         memcpy(cp, s, octets);
24
25         return cp;
26 }
27 #else
28 int strdup_c_nonempty_compilation_unit;
29 #endif