src.ctf.fs: make ctf_fs_trace::metadata a unique_ptr
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 9 Jun 2022 15:19:30 +0000 (11:19 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 17 Apr 2024 17:57:53 +0000 (13:57 -0400)
Introduce ctf_fs_metadata::UP and change the ctf_fs_trace::metadata
field to be of that type.

Change-Id: I0221ef7786cc8fb4c2e8a9264573ab5c2e5420d6
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8286
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12324
Tested-by: jenkins <jenkins@lttng.org>
src/plugins/ctf/fs-src/data-stream-file.cpp
src/plugins/ctf/fs-src/fs.cpp
src/plugins/ctf/fs-src/fs.hpp

index caad4b58123d1d341e5ca82c685d317a6fcfd740..24b32a2bab175c1f556da1b0a061313dcd4f7868 100644 (file)
@@ -811,7 +811,7 @@ ctf_fs_ds_file::UP ctf_fs_ds_file_create(struct ctf_fs_trace *ctf_fs_trace,
     }
 
     ds_file->stream = std::move(stream);
-    ds_file->metadata = ctf_fs_trace->metadata;
+    ds_file->metadata = ctf_fs_trace->metadata.get();
     ds_file->file->path = path;
     ret = ctf_fs_file_open(ds_file->file.get(), "rb");
     if (ret) {
index 2b2f5bc4b6f29acf53a67ae6a550ac9531510a31..6c125461275b67aa40642f24838f7447dbb54a7a 100644 (file)
@@ -261,10 +261,6 @@ static void ctf_fs_trace_destroy(struct ctf_fs_trace *ctf_fs_trace)
         return;
     }
 
-    if (ctf_fs_trace->metadata) {
-        delete ctf_fs_trace->metadata;
-    }
-
     delete ctf_fs_trace;
 }
 
@@ -745,7 +741,7 @@ static ctf_fs_trace::UP ctf_fs_trace_create(const char *path, const char *name,
     ctf_fs_trace::UP ctf_fs_trace {new struct ctf_fs_trace(parentLogger)};
 
     ctf_fs_trace->path = path;
-    ctf_fs_trace->metadata = new ctf_fs_metadata;
+    ctf_fs_trace->metadata = bt2s::make_unique<ctf_fs_metadata>();
 
     ret = ctf_fs_metadata_set_trace_class(selfComp, ctf_fs_trace.get(), clkClsCfg);
     if (ret) {
index 49223bfea119d4e85ced720d854fe543225e86ce..bd9bfb9767e9a6292eb450c7883a13816840d7d1 100644 (file)
@@ -24,6 +24,8 @@ extern bool ctf_fs_debug;
 
 struct ctf_fs_metadata
 {
+    using UP = std::unique_ptr<ctf_fs_metadata>;
+
     /* Owned by this */
     ctf_metadata_decoder_up decoder;
 
@@ -51,8 +53,7 @@ struct ctf_fs_trace
 
     bt2c::Logger logger;
 
-    /* Owned by this */
-    struct ctf_fs_metadata *metadata = nullptr;
+    ctf_fs_metadata::UP metadata;
 
     bt2::Trace::Shared trace;
 
This page took 0.026532 seconds and 4 git commands to generate.