]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Context: move ignore_headers_len, remove cc_reset()
authorThomas Otto <thomas.otto@pdv-fs.de>
Mon, 27 Jan 2020 18:57:23 +0000 (19:57 +0100)
committerThomas Otto <thomas.otto@pdv-fs.de>
Mon, 17 Feb 2020 21:06:17 +0000 (22:06 +0100)
Makefile.in
src/Context.cpp
src/Context.hpp
src/ccache.cpp
src/legacy_globals.cpp
src/legacy_globals.hpp
src/manifest.cpp
unittest/test_argument_processing.cpp

index ebd29d833e4d968e8192388d8df06784acd58ea9..4657726425c82b8df2bc6e59d444f1cf4096159c 100644 (file)
@@ -59,7 +59,6 @@ non_third_party_sources = \
     src/hash.cpp \
     src/hashutil.cpp \
     src/language.cpp \
-    src/legacy_globals.cpp \
     src/legacy_util.cpp \
     src/lockfile.cpp \
     src/logging.cpp \
index 699bb2308b24b00167e13778ba61e9ef3ebfd87b..2d73cc13b91a7cb3f3593e68182237fc6203b702 100644 (file)
@@ -32,4 +32,9 @@ Context::~Context()
   args_free(orig_args);
 
   free(result_name);
+
+  for (size_t i = 0; i < ignore_headers_len; i++) {
+    free(ignore_headers[i]);
+  }
+  free(ignore_headers);
 }
index 56358cf2cb29b597c4c37b9e7d573ac96c015571..cc1e53e78c2b90cc0c7d4882ba063933ccddb05a 100644 (file)
@@ -89,4 +89,8 @@ struct Context : NonCopyable
 
   // The .gch/.pch/.pth file used for compilation.
   std::string included_pch_file;
+
+  // List of headers to ignore.
+  char** ignore_headers = nullptr;
+  size_t ignore_headers_len = 0;
 };
index d93d7cf6ce3e0e84063cb3cb9fb7a8f42346da32..805fc8de0a0d52f168bce7e3d5e6659d5260ae48 100644 (file)
@@ -35,7 +35,6 @@
 #include "hash.hpp"
 #include "hashutil.hpp"
 #include "language.hpp"
-#include "legacy_globals.hpp"
 #include "logging.hpp"
 #include "manifest.hpp"
 #include "result.hpp"
@@ -480,8 +479,8 @@ do_remember_include_file(Context& ctx,
       canonical_len -= 2;
     }
 
-    for (size_t i = 0; i < ignore_headers_len; i++) {
-      char* ignore = ignore_headers[i];
+    for (size_t i = 0; i < ctx.ignore_headers_len; i++) {
+      char* ignore = ctx.ignore_headers[i];
       size_t ignore_len = strlen(ignore);
       if (ignore_len > canonical_len) {
         continue;
@@ -699,16 +698,16 @@ process_preprocessed_file(Context& ctx,
     return false;
   }
 
-  ignore_headers = NULL;
-  ignore_headers_len = 0;
+  ctx.ignore_headers = nullptr;
+  ctx.ignore_headers_len = 0;
   if (!ctx.config.ignore_headers_in_manifest().empty()) {
     char *header, *p, *q, *saveptr = NULL;
     p = x_strdup(ctx.config.ignore_headers_in_manifest().c_str());
     q = p;
     while ((header = strtok_r(q, PATH_DELIM, &saveptr))) {
-      ignore_headers = static_cast<char**>(
-        x_realloc(ignore_headers, (ignore_headers_len + 1) * sizeof(char*)));
-      ignore_headers[ignore_headers_len++] = x_strdup(header);
+      ctx.ignore_headers = static_cast<char**>(x_realloc(
+        ctx.ignore_headers, (ctx.ignore_headers_len + 1) * sizeof(char*)));
+      ctx.ignore_headers[ctx.ignore_headers_len++] = x_strdup(header);
       q = NULL;
     }
     free(p);
@@ -3520,25 +3519,6 @@ initialize(int argc, char* argv[])
   return *ctx;
 }
 
-template<class T>
-static void
-free_and_nullify(T*& ptr)
-{
-  free(ptr);
-  ptr = NULL;
-}
-
-// Reset the global state. Used by the test suite.
-void
-cc_reset()
-{
-  for (size_t i = 0; i < ignore_headers_len; i++) {
-    free_and_nullify(ignore_headers[i]);
-  }
-  free_and_nullify(ignore_headers);
-  ignore_headers_len = 0;
-}
-
 // Make a copy of stderr that will not be cached, so things like distcc can
 // send networking errors to it.
 static void
index 1bac9882a9161b246ff0cde6f9fa23be4dbce423..f1c23fc2973b88b6173e1ccc78cb029fabbba0b1 100644 (file)
 
 #include "legacy_globals.hpp"
 
-// List of headers to ignore.
-char** ignore_headers;
-
-// Size of headers to ignore list.
-size_t ignore_headers_len;
-
 // How long (in microseconds) to wait before breaking a stale lock.
 unsigned lock_staleness_limit = 2000000;
index bb083fc7ef79a840e5fa7d2c739307572bb3a83a..8dba783bd80241a014066e9427b3fbbc881f3660 100644 (file)
@@ -29,7 +29,3 @@
 // variable descriptions are in the .cpp file
 
 extern unsigned lock_staleness_limit;
-
-extern char** ignore_headers;
-
-extern size_t ignore_headers_len;
index ccdee31dfe1c66d6cb9a738c6cbc82e327726f49..764a948719f5c31da82c020d431592144277cbea 100644 (file)
@@ -29,7 +29,6 @@
 #include "ccache.hpp"
 #include "hash.hpp"
 #include "hashutil.hpp"
-#include "legacy_globals.hpp"
 #include "logging.hpp"
 
 // Manifest data format
index caadfb069d17b988a6c91a2ce0bfb9c49056dc86..37cd5f7326b9ccac55fd1954f6f5781cf056c7a3 100644 (file)
@@ -23,7 +23,6 @@
 #include "../src/Util.hpp"
 #include "../src/args.hpp"
 #include "../src/ccache.hpp"
-#include "../src/legacy_globals.hpp"
 #include "../src/stats.hpp"
 #include "framework.hpp"
 #include "util.hpp"