File: strdup.c

package info (click to toggle)
ntp 1%3A4.2.8p10%2Bdfsg-3%2Bdeb9u2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 32,104 kB
  • sloc: ansic: 237,718; sh: 6,873; makefile: 3,381; perl: 2,645; python: 1,473; yacc: 1,413; ruby: 816; awk: 417; sed: 47; asm: 37
file content (29 lines) | stat: -rw-r--r-- 386 bytes parent folder | download | duplicates (2)
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
#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