freebsd-skq/contrib/ntp/libntp/strdup.c
2015-07-05 15:42:16 +00:00

30 lines
386 B
C

#include <config.h>
#include <ntp_assert.h>
#include "ntp_malloc.h"
#include <string.h>
#ifndef HAVE_STRDUP
char *strdup(const char *s);
char *
strdup(
const char *s
)
{
size_t octets;
char * cp;
REQUIRE(s);
octets = strlen(s) + 1;
if ((cp = malloc(octets)) == NULL)
return NULL;
memcpy(cp, s, octets);
return cp;
}
#else
int strdup_c_nonempty_compilation_unit;
#endif