]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Context: move i_tmpfile and converted to std::string
authorThomas Otto <thomas.otto@pdv-fs.de>
Sat, 25 Jan 2020 10:00:35 +0000 (11:00 +0100)
committerThomas Otto <thomas.otto@pdv-fs.de>
Mon, 17 Feb 2020 21:06:17 +0000 (22:06 +0100)
src/Context.hpp
src/ccache.cpp
src/legacy_globals.cpp
src/legacy_globals.hpp

index 4931ebc63a6a13a210eaab7a2549464c5e4dd4e6..74eb4e30eac1b17008486c29233d8a67c5349a95 100644 (file)
@@ -72,4 +72,7 @@ struct Context : NonCopyable
 
   // Uses absolute path for some include files.
   bool has_absolute_include_headers = false;
+
+  // The name of the temporary preprocessed file.
+  std::string i_tmpfile;
 };
index a15b58d636d00df71ea375809abfd9defde8cb37..d7f4f60a9f5a943bc2ce96e171e878e8216e5ec8 100644 (file)
@@ -1146,7 +1146,7 @@ to_cache(Context& ctx,
   if (ctx.config.run_second_cpp()) {
     args_add(args, ctx.args_info.input_file.c_str());
   } else {
-    args_add(args, i_tmpfile);
+    args_add(args, ctx.i_tmpfile.c_str());
   }
 
   if (ctx.args_info.seen_split_dwarf) {
@@ -1457,14 +1457,14 @@ get_result_name_from_cpp(Context& ctx, struct args* args, struct hash* hash)
   }
 
   if (ctx.args_info.direct_i_file) {
-    i_tmpfile = x_strdup(ctx.args_info.input_file.c_str());
+    ctx.i_tmpfile = ctx.args_info.input_file;
   } else {
     // i_tmpfile needs the proper cpp_extension for the compiler to do its
     // thing correctly
-    i_tmpfile =
-      format("%s.%s", path_stdout, ctx.config.cpp_extension().c_str());
-    x_rename(path_stdout, i_tmpfile);
-    add_pending_tmp_file(i_tmpfile);
+    ctx.i_tmpfile =
+      fmt::format("{}.{}", path_stdout, ctx.config.cpp_extension());
+    x_rename(path_stdout, ctx.i_tmpfile.c_str());
+    add_pending_tmp_file(ctx.i_tmpfile.c_str());
   }
 
   if (ctx.config.run_second_cpp()) {
@@ -3531,7 +3531,6 @@ cc_reset()
   }
   free_and_nullify(ignore_headers);
   ignore_headers_len = 0;
-  i_tmpfile = NULL;
   free_and_nullify(cpp_stderr);
 }
 
index 80898479c3cba1b3c69766aecbf84b068e8fd35e..0359c8756abfacc5b3e438b62948ac51b3bd2a91 100644 (file)
@@ -24,9 +24,6 @@ char** ignore_headers;
 // Size of headers to ignore list.
 size_t ignore_headers_len;
 
-// The name of the temporary preprocessed file.
-char* i_tmpfile;
-
 // The name of the cpp stderr file.
 char* cpp_stderr;
 
index eba4d1400ccc2807577b345be97c1d11c7d24c83..b6a695b063563cf25750f93402162b3a48270023 100644 (file)
@@ -34,8 +34,6 @@ extern char** ignore_headers;
 
 extern size_t ignore_headers_len;
 
-extern char* i_tmpfile;
-
 extern char* cpp_stderr;
 
 extern char* manifest_stats_file;