diff options
author | Cy Schubert <cy@FreeBSD.org> | 2015-07-01 03:12:13 +0000 |
---|---|---|
committer | Cy Schubert <cy@FreeBSD.org> | 2015-07-01 03:12:13 +0000 |
commit | 873997f35a991eee09ed91148a0cf332360380da (patch) | |
tree | 5b1ffa3ad0e56e0e9f2991011729791ee86d7632 /libntp/strdup.c | |
parent | 4ba32eb5a8bf3455c09d1513ed2af8d2c861a6ba (diff) |
Notes
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; |