xref: /netbsd-src/external/bsd/ntp/dist/libntp/strdup.c (revision b1c86f5f087524e68db12794ee9c3e3da1ab17a0)
1 /*	$NetBSD: strdup.c,v 1.1.1.1 2009/12/13 16:55:05 kardel Exp $	*/
2 
3 #include "ntp_malloc.h"
4 
5 #if !HAVE_STRDUP
6 
7 #define NULL 0
8 
9 char *strdup(const char *s);
10 
11 char *
12 strdup(
13 	const char *s
14 	)
15 {
16         char *cp;
17 
18         if (s) {
19                 cp = (char *) malloc((unsigned) (strlen(s)+1));
20                 if (cp) {
21                         (void) strcpy(cp, s);
22 		}
23         } else {
24                 cp = (char *) NULL;
25 	}
26         return(cp);
27 }
28 #else
29 int strdup_bs;
30 #endif
31