diff options
Diffstat (limited to 'libntp/strdup.c')
-rw-r--r-- | libntp/strdup.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/libntp/strdup.c b/libntp/strdup.c index f7565a2fb8f7..62d5a16d433c 100644 --- a/libntp/strdup.c +++ b/libntp/strdup.c @@ -1,7 +1,8 @@ #include <config.h> -#include <string.h> +#include <ntp_assert.h> #include "ntp_malloc.h" +#include <string.h> #ifndef HAVE_STRDUP @@ -15,15 +16,13 @@ strdup( size_t octets; char * cp; - if (s) { - octets = 1 + strlen(s); - cp = malloc(octets); - if (NULL != cp) - memcpy(cp, s, octets); - else - cp = NULL; + REQUIRE(s); + octets = strlen(s) + 1; + if ((cp = malloc(octets)) == NULL) + return NULL; + memcpy(cp, s, octets); - return(cp); + return cp; } #else int strdup_c_nonempty_compilation_unit; |