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

#include <config.h>

#include <string.h>
#include "ntp_malloc.h"

#ifndef HAVE_STRDUP

char *strdup(const char *s);

char *
strdup(
	const char *s
	)
{
	size_t	octets;
	char *	cp;

	if (s) {
		octets = 1 + strlen(s);
		cp = malloc(octets);
		if (NULL != cp)
			memcpy(cp, s, octets);
	else
		cp = NULL;

	return(cp);
}
#else
int strdup_c_nonempty_compilation_unit;
#endif

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