xref: /netbsd-src/external/bsd/ntp/dist/sntp/libopts/compat/strdup.c (revision 63aea4bd5b445e491ff0389fe27ec78b3099dba3)
1 /*	$NetBSD: strdup.c,v 1.3 2015/07/10 14:20:35 christos Exp $	*/
2 
3 /*
4  * Platforms without strdup ?!?!?!
5  */
6 
7 static char *
8 strdup( char const *s );
9 
10 static char *
11 strdup( char const *s )
12 {
13     char *cp;
14 
15     if (s == NULL)
16         return NULL;
17 
18     cp = (char *) AGALOC((unsigned) (strlen(s)+1), "strdup");
19 
20     if (cp != NULL)
21         (void) strcpy(cp, s);
22 
23     return cp;
24 }
25