src.ctf.fs: rename ctf_fs_ds_file_destroy to ~ctf_fs_ds_file
authorSimon Marchi <simon.marchi@efficios.com>
Tue, 5 Dec 2023 03:42:10 +0000 (03:42 +0000)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 17 Apr 2024 17:57:53 +0000 (13:57 -0400)
This makes the ctf_fs_ds_file type deletable.

Change-Id: Ibaedb136777a39db11a1bd30355c7123e186e489
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8267
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12305
Tested-by: jenkins <jenkins@lttng.org>
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 e73f28f3729298fcf8885d722fcc49f09e3a0496..9f5c5410e6eccab5a65b39a5f9bd1bc037cad833 100644 (file)
@@ -324,7 +324,7 @@ ctf_fs_ds_group_medops_set_file(struct ctf_fs_ds_group_medops_data *data,
     /* Check if that file is already the one mapped. */
     if (!data->file || data->file->file->path != index_entry->path) {
         /* Destroy the previously used file. */
-        ctf_fs_ds_file_destroy(data->file);
+        delete data->file;
 
         /* Create the new file. */
         data->file =
@@ -388,7 +388,7 @@ void ctf_fs_ds_group_medops_data_destroy(struct ctf_fs_ds_group_medops_data *dat
         goto end;
     }
 
-    ctf_fs_ds_file_destroy(data->file);
+    delete data->file;
 
     delete data;
 
@@ -843,7 +843,7 @@ struct ctf_fs_ds_file *ctf_fs_ds_file_create(struct ctf_fs_trace *ctf_fs_trace,
 
 error:
     /* Do not touch "borrowed" file. */
-    ctf_fs_ds_file_destroy(ds_file);
+    delete ds_file;
     ds_file = NULL;
 
 end:
@@ -871,15 +871,9 @@ ctf_fs_ds_index::UP ctf_fs_ds_index_create()
     return bt2s::make_unique<ctf_fs_ds_index>();
 }
 
-void ctf_fs_ds_file_destroy(struct ctf_fs_ds_file *ds_file)
+ctf_fs_ds_file::~ctf_fs_ds_file()
 {
-    if (!ds_file) {
-        return;
-    }
-
-    (void) ds_file_munmap(ds_file);
-
-    delete ds_file;
+    (void) ds_file_munmap(this);
 }
 
 ctf_fs_ds_file_info::UP ctf_fs_ds_file_info_create(const char *path, int64_t begin_ns)
index a1226474fc71a8ab798695f4b548cf512d6d2c6d..8ffc670d948d9aa9639eefdb6e90598dcac09d07 100644 (file)
@@ -40,6 +40,10 @@ struct ctf_fs_ds_file
     {
     }
 
+    ctf_fs_ds_file(const ctf_fs_ds_file&) = delete;
+    ctf_fs_ds_file& operator=(const ctf_fs_ds_file&) = delete;
+    ~ctf_fs_ds_file();
+
     bt2c::Logger logger;
 
     /* Weak */
@@ -145,8 +149,6 @@ struct ctf_fs_ds_file_group
 struct ctf_fs_ds_file *ctf_fs_ds_file_create(ctf_fs_trace *ctf_fs_trace, bt2::Stream::Shared stream,
                                              const char *path, const bt2c::Logger& logger);
 
-void ctf_fs_ds_file_destroy(struct ctf_fs_ds_file *stream);
-
 ctf_fs_ds_index::UP ctf_fs_ds_file_build_index(struct ctf_fs_ds_file *ds_file,
                                                struct ctf_fs_ds_file_info *ds_file_info,
                                                struct ctf_msg_iter *msg_iter);
index 272e98d51732abd5c5aa6e0b1b21edaab645906b..4405ca2fa0e31aa2b6d67e8c3eb6f9a30c5ee913 100644 (file)
@@ -640,7 +640,7 @@ error:
     ret = -1;
 
 end:
-    ctf_fs_ds_file_destroy(ds_file);
+    delete ds_file;
 
     if (msg_iter) {
         ctf_msg_iter_destroy(msg_iter);
@@ -1193,9 +1193,8 @@ static int decode_clock_snapshot_after_event(struct ctf_fs_trace *ctf_fs_trace,
     }
 
 end:
-    if (ds_file) {
-        ctf_fs_ds_file_destroy(ds_file);
-    }
+    delete ds_file;
+
     if (msg_iter) {
         ctf_msg_iter_destroy(msg_iter);
     }
This page took 0.027886 seconds and 4 git commands to generate.