]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
C++-ify Context::result_name
authorJoel Rosdahl <joel@rosdahl.net>
Sun, 19 Apr 2020 14:47:00 +0000 (16:47 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 19 Apr 2020 14:53:10 +0000 (16:53 +0200)
src/Context.cpp
src/Context.hpp
src/ccache.cpp

index 078f04f5b3138417c822a6dd37f84b4577461060..6cfe7f657780025bd3808e69a55ae973e51b11d3 100644 (file)
@@ -26,8 +26,3 @@ Context::Context()
     apparent_cwd(Util::get_apparent_cwd(actual_cwd))
 {
 }
-
-Context::~Context()
-{
-  free(result_name);
-}
index 6ab909003f9472e6e976b6fcf65dcd6f611cf6ac..7845f1a2104a1a94c5eb68f696145225bc4b971b 100644 (file)
@@ -27,6 +27,8 @@
 #include "ccache.hpp"
 #include "hash.hpp"
 
+#include "third_party/nonstd/optional.hpp"
+
 #include <string>
 #include <unordered_map>
 #include <vector>
@@ -34,7 +36,6 @@
 struct Context : NonCopyable
 {
   Context();
-  ~Context();
 
   ArgsInfo args_info;
   Config config;
@@ -50,7 +51,7 @@ struct Context : NonCopyable
 
   // Name (represented as a struct digest) of the file containing the cached
   // result.
-  struct digest* result_name = nullptr;
+  nonstd::optional<struct digest> result_name;
 
   // Full path to the file containing the result
   // (cachedir/a/b/cdef[...]-size.result).
index a3ebf606ce29f4d7023f8d2fe9bfe0886b58f272..78af8e0f20e4587a97284a1b86f8139a3c9a122b 100644 (file)
@@ -1009,7 +1009,7 @@ update_cached_result_globals(Context& ctx, struct digest* result_name)
 {
   char result_name_string[DIGEST_STRING_BUFFER_SIZE];
   digest_as_string(result_name, result_name_string);
-  ctx.result_name = result_name;
+  ctx.result_name = *result_name;
   ctx.result_path = Util::get_path_in_cache(ctx.config.cache_dir(),
                                             ctx.config.cache_dir_levels(),
                                             result_name_string,