From: Joel Rosdahl Date: Mon, 27 Jul 2020 18:26:42 +0000 (+0200) Subject: Remove now unused legacy x_strndup function X-Git-Tag: v4.0~280 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ffa957b1568870781009b4bde09b2efab9be536b;p=thirdparty%2Fccache.git Remove now unused legacy x_strndup function --- diff --git a/src/legacy_util.cpp b/src/legacy_util.cpp index 111f6fc9a..cc08056db 100644 --- a/src/legacy_util.cpp +++ b/src/legacy_util.cpp @@ -274,32 +274,6 @@ x_strdup(const char* s) return ret; } -// This is like strndup() but dies if the malloc fails. -char* -x_strndup(const char* s, size_t n) -{ -#ifndef HAVE_STRNDUP - if (!s) { - return NULL; - } - size_t m = 0; - while (m < n && s[m]) { - m++; - } - char* ret = static_cast(malloc(m + 1)); - if (ret) { - memcpy(ret, s, m); - ret[m] = '\0'; - } -#else - char* ret = strndup(s, n); -#endif - if (!ret) { - fatal("x_strndup: Could not allocate %lu bytes", (unsigned long)n); - } - return ret; -} - // This is like setenv. void x_setenv(const char* name, const char* value) diff --git a/src/legacy_util.hpp b/src/legacy_util.hpp index 2519fd2b2..4ec3ac269 100644 --- a/src/legacy_util.hpp +++ b/src/legacy_util.hpp @@ -32,7 +32,6 @@ bool move_file(const char* src, const char* dest); const char* get_hostname(); char* format(const char* format, ...) ATTR_FORMAT(printf, 1, 2); char* x_strdup(const char* s); -char* x_strndup(const char* s, size_t n); void x_setenv(const char* name, const char* value); void x_unsetenv(const char* name); #ifndef HAVE_LOCALTIME_R