summaryrefslogtreecommitdiff
path: root/libntp/strdup.c
blob: f7565a2fb8f75a960042bfb6509dc874a8fbb7d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#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