strdup.c revision 1.5
1/* $NetBSD: strdup.c,v 1.5 2020/05/25 20:47:35 christos Exp $ */ 2 3/* 4 * Platforms without strdup ?!?!?! 5 */ 6 7static char * 8strdup( char const *s ); 9 10static char * 11strdup( 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