From: Simon Marchi Date: Tue, 5 Dec 2023 03:42:10 +0000 (+0000) Subject: src.ctf.fs: rename ctf_fs_ds_file_destroy to ~ctf_fs_ds_file X-Git-Url: https://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=3199f1bafdb9e80278a77a9a629f6208eb0a5d52 src.ctf.fs: rename ctf_fs_ds_file_destroy to ~ctf_fs_ds_file This makes the ctf_fs_ds_file type deletable. Change-Id: Ibaedb136777a39db11a1bd30355c7123e186e489 Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/8267 Reviewed-by: Philippe Proulx Reviewed-on: https://review.lttng.org/c/babeltrace/+/12305 Tested-by: jenkins --- diff --git a/src/plugins/ctf/fs-src/data-stream-file.cpp b/src/plugins/ctf/fs-src/data-stream-file.cpp index e73f28f3..9f5c5410 100644 --- a/src/plugins/ctf/fs-src/data-stream-file.cpp +++ b/src/plugins/ctf/fs-src/data-stream-file.cpp @@ -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(); } -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) diff --git a/src/plugins/ctf/fs-src/data-stream-file.hpp b/src/plugins/ctf/fs-src/data-stream-file.hpp index a1226474..8ffc670d 100644 --- a/src/plugins/ctf/fs-src/data-stream-file.hpp +++ b/src/plugins/ctf/fs-src/data-stream-file.hpp @@ -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); diff --git a/src/plugins/ctf/fs-src/fs.cpp b/src/plugins/ctf/fs-src/fs.cpp index 272e98d5..4405ca2f 100644 --- a/src/plugins/ctf/fs-src/fs.cpp +++ b/src/plugins/ctf/fs-src/fs.cpp @@ -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); }