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