File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / ntp / libntp / strdup.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue May 29 12:08:38 2012 UTC (12 years, 1 month ago) by misho
Branches: ntp, MAIN
CVS tags: v4_2_6p5p0, v4_2_6p5, HEAD
ntp 4.2.6p5

    1: #include <config.h>
    2: 
    3: #include <string.h>
    4: #include "ntp_malloc.h"
    5: 
    6: #ifndef HAVE_STRDUP
    7: 
    8: char *strdup(const char *s);
    9: 
   10: char *
   11: strdup(
   12: 	const char *s
   13: 	)
   14: {
   15: 	size_t	octets;
   16: 	char *	cp;
   17: 
   18: 	if (s) {
   19: 		octets = 1 + strlen(s);
   20: 		cp = malloc(octets);
   21: 		if (NULL != cp)
   22: 			memcpy(cp, s, octets);
   23: 	else
   24: 		cp = NULL;
   25: 
   26: 	return(cp);
   27: }
   28: #else
   29: int strdup_c_nonempty_compilation_unit;
   30: #endif

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>