mirror of
https://github.com/Stichting-MINIX-Research-Foundation/netbsd.git
synced 2025-08-09 05:59:13 -04:00
33 lines
440 B
C
33 lines
440 B
C
/* $NetBSD: strdup.c,v 1.1.1.2 2012/01/31 21:23:56 kardel Exp $ */
|
|
|
|
#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
|