xref: /freebsd/contrib/ntp/libntp/strdup.c (revision 1e413cf93298b5b97441a21d9a50fdcd0ee9945e)
1 #include "ntp_malloc.h"
2 
3 #if !HAVE_STRDUP
4 
5 #define NULL 0
6 
7 char *strdup(const char *s);
8 
9 char *
10 strdup(
11 	const char *s
12 	)
13 {
14         char *cp;
15 
16         if (s) {
17                 cp = (char *) malloc((unsigned) (strlen(s)+1));
18                 if (cp) {
19                         (void) strcpy(cp, s);
20 		}
21         } else {
22                 cp = (char *) NULL;
23 	}
24         return(cp);
25 }
26 #else
27 int strdup_bs;
28 #endif
29