]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Remove now unused legacy x_strndup function
authorJoel Rosdahl <joel@rosdahl.net>
Mon, 27 Jul 2020 18:26:42 +0000 (20:26 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Tue, 28 Jul 2020 12:00:30 +0000 (14:00 +0200)
src/legacy_util.cpp
src/legacy_util.hpp

index 111f6fc9ac7352c6949b9d906c5addf272ba8fdf..cc08056db4ca96edc6f9ac6f7b32bb94a0fa5d47 100644 (file)
@@ -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<char*>(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)
index 2519fd2b237640f0eaca10d77551e46c06f3fb62..4ec3ac2690b76b67598008ca5bfc4eca76ac5943 100644 (file)
@@ -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