diff options
Diffstat (limited to 'libntp/strdup.c')
-rw-r--r-- | libntp/strdup.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/libntp/strdup.c b/libntp/strdup.c new file mode 100644 index 0000000..f7565a2 --- /dev/null +++ b/libntp/strdup.c @@ -0,0 +1,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 |