]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Simplify (non-)freeing of orig_args on failure
authorJoel Rosdahl <joel@rosdahl.net>
Sun, 16 Feb 2020 20:11:18 +0000 (21:11 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 16 Feb 2020 20:19:31 +0000 (21:19 +0100)
src/Context.cpp
src/Context.hpp
src/ccache.cpp

index 35380752d0d524b15189e4e68e80644e31c3e1a6..c60df719a444cb48f6e3b1fba9f4de4ab5a37da5 100644 (file)
@@ -22,7 +22,5 @@
 
 Context::~Context()
 {
-  if (free_orig_args) {
-    args_free(orig_args);
-  }
+  args_free(orig_args);
 }
index afe8b4d565176909716c91edd19d66b449089d3f..26862207196be71b09cb298dc54652153ba247b9 100644 (file)
@@ -40,7 +40,4 @@ struct Context : NonCopyable
 
   // The original argument list.
   struct args* orig_args = nullptr;
-
-  // Whether to free orig_args in the destructor.
-  bool free_orig_args = true;
 };
index bd2964f6c48bf49ab7a7a1bef4cf42c0f2e42444..b5be7935571d259ccdc0a3ea5a5a79670004e4c0 100644 (file)
@@ -3641,8 +3641,8 @@ cache_compilation(int argc, char* argv[])
 
     cc_log("Failed; falling back to running the real compiler");
     cc_log_argv("Executing ", ctx.orig_args->argv);
-    ctx.free_orig_args = false;
     struct args* orig_args_for_execv = ctx.orig_args;
+    ctx.orig_args = nullptr; // Take over ownership.
     exitfn_call();
     execv(orig_args_for_execv->argv[0], orig_args_for_execv->argv);
     fatal(