aboutsummaryrefslogblamecommitdiffstats
path: root/libntp/strdup.c
blob: 62d5a16d433c611b5bf9cce27857bf40d77a88b0 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
                   
 
                       
                       
                   
 
                   
 

                            




                     


                       




                                          
 
                  
 
     
                                       
      
#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