diff --git a/src/acfutils/helpers.h b/src/acfutils/helpers.h index a6da64f9..c1d4d77c 100644 --- a/src/acfutils/helpers.h +++ b/src/acfutils/helpers.h @@ -41,7 +41,6 @@ #include /* to bring in DIR, opendir, readdir & friends */ #include #endif -#include #if IBM #include @@ -54,6 +53,7 @@ #include "math_core.h" #include "sysmacros.h" #include "safe_alloc.h" +#include "time.h" #include "types.h" #ifdef __cplusplus diff --git a/src/acfutils/safe_alloc.h b/src/acfutils/safe_alloc.h index f49e4012..77945d47 100644 --- a/src/acfutils/safe_alloc.h +++ b/src/acfutils/safe_alloc.h @@ -92,11 +92,13 @@ safe_realloc(void *oldptr, size_t size) static inline char * safe_strdup(const char *str2) { - char *str = strdup(str2); - if (str2 != NULL) { - VERIFY_MSG(str != NULL, "Cannot allocate %lu bytes: " - "out of memory", (long unsigned)strlen(str2) + 1); - } + char *str; + int l; + ASSERT(str2 != NULL); + l = strlen(str2); + str = (char *)safe_malloc(l + 1); + memcpy(str, str2, l); + str[l] = '\0'; return (str); }