src.ctf.fs: make ctf_fs_ds_file_info_create return a unique_ptr
authorSimon Marchi <simon.marchi@efficios.com>
Mon, 11 Dec 2023 17:23:19 +0000 (12:23 -0500)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 17 Apr 2024 17:57:53 +0000 (13:57 -0400)
Introduce ctf_fs_ds_file_info::UP, make ctf_fs_ds_file_info_create
return it.  We don't need a custom deleter, because ctf_fs_ds_file_info
can simply be deleted.  ctf_fs_ds_file_info_destroy will disappear in
the next patches.

Change-Id: Iae4fdf68035d45762f2606685f712fd12976f008
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8249
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12287

src/plugins/ctf/fs-src/data-stream-file.cpp
src/plugins/ctf/fs-src/data-stream-file.hpp
src/plugins/ctf/fs-src/fs.cpp

index c1fcad2729d17b84768efbe14213489a282fc690..aa27c95943321672bb097f6b04e5532d51f05560 100644 (file)
@@ -12,6 +12,7 @@
 
 #include "compat/endian.h" /* IWYU pragma: keep  */
 #include "compat/mman.h"   /* IWYU: pragma keep  */
+#include "cpp-common/bt2s/make-unique.hpp"
 #include "cpp-common/vendor/fmt/format.h"
 
 #include "../common/src/msg-iter/msg-iter.hpp"
@@ -935,9 +936,9 @@ void ctf_fs_ds_file_info_destroy(struct ctf_fs_ds_file_info *ds_file_info)
     delete ds_file_info;
 }
 
-struct ctf_fs_ds_file_info *ctf_fs_ds_file_info_create(const char *path, int64_t begin_ns)
+ctf_fs_ds_file_info::UP ctf_fs_ds_file_info_create(const char *path, int64_t begin_ns)
 {
-    ctf_fs_ds_file_info *ds_file_info = new ctf_fs_ds_file_info;
+    ctf_fs_ds_file_info::UP ds_file_info = bt2s::make_unique<ctf_fs_ds_file_info>();
 
     ds_file_info->path = path;
     ds_file_info->begin_ns = begin_ns;
index 6b5c3db71efb0ca4715c42e345a0bbc69703b2bb..86cc218b854e7f1e31e5596f049fb21cf80cc576 100644 (file)
@@ -22,6 +22,8 @@
 
 struct ctf_fs_ds_file_info
 {
+    using UP = std::unique_ptr<ctf_fs_ds_file_info>;
+
     std::string path;
 
     /* Guaranteed to be set, as opposed to the index. */
@@ -162,7 +164,7 @@ void ctf_fs_ds_index_destroy(struct ctf_fs_ds_index *index);
 
 void ctf_fs_ds_file_info_destroy(struct ctf_fs_ds_file_info *ds_file_info);
 
-struct ctf_fs_ds_file_info *ctf_fs_ds_file_info_create(const char *path, int64_t begin_ns);
+ctf_fs_ds_file_info::UP ctf_fs_ds_file_info_create(const char *path, int64_t begin_ns);
 
 ctf_fs_ds_file_group::UP ctf_fs_ds_file_group_create(struct ctf_fs_trace *ctf_fs_trace,
                                                      struct ctf_stream_class *sc,
index 40ef74397f573842700c72fde73cd59c1a8636b6..8bc130b13dda3a84d267cc36cffe5961017d265c 100644 (file)
@@ -601,7 +601,7 @@ static int add_ds_file_to_ds_file_group(struct ctf_fs_trace *ctf_fs_trace, const
         }
     }
 
-    ds_file_info = ctf_fs_ds_file_info_create(path, begin_ns);
+    ds_file_info = ctf_fs_ds_file_info_create(path, begin_ns).release();
     if (!ds_file_info) {
         goto error;
     }
This page took 0.026791 seconds and 4 git commands to generate.