From 57ec0a3533f05546d9988deca01ee6e3695357a9 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Tue, 5 Dec 2023 04:11:57 +0000 Subject: [PATCH] src.ctf.fs: remove ctf_fs_destroy Remove it, since a ctf_fs_destroy instance can simply be deleted. Change-Id: Ic6b879dbdff5e5172c2f07c810f97ceaf45a77f9 Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/8274 Reviewed-by: Philippe Proulx Reviewed-on: https://review.lttng.org/c/babeltrace/+/12312 Tested-by: jenkins --- src/plugins/ctf/fs-src/fs.cpp | 20 +++----------------- src/plugins/ctf/fs-src/fs.hpp | 11 +---------- 2 files changed, 4 insertions(+), 27 deletions(-) diff --git a/src/plugins/ctf/fs-src/fs.cpp b/src/plugins/ctf/fs-src/fs.cpp index f2582a82..b1ac21d1 100644 --- a/src/plugins/ctf/fs-src/fs.cpp +++ b/src/plugins/ctf/fs-src/fs.cpp @@ -296,29 +296,15 @@ void ctf_fs_trace_deleter::operator()(ctf_fs_trace * const trace) noexcept ctf_fs_trace_destroy(trace); } -void ctf_fs_destroy(struct ctf_fs_component *ctf_fs) -{ - if (!ctf_fs) { - return; - } - - delete ctf_fs; -} - -void ctf_fs_component_deleter::operator()(ctf_fs_component *comp) -{ - ctf_fs_destroy(comp); -} - ctf_fs_component::UP ctf_fs_component_create(const bt2c::Logger& parentLogger) { - return ctf_fs_component::UP {new ctf_fs_component {parentLogger}}; + return bt2s::make_unique(parentLogger); } void ctf_fs_finalize(bt_self_component_source *component) { - ctf_fs_destroy((struct ctf_fs_component *) bt_self_component_get_data( - bt_self_component_source_as_self_component(component))); + ctf_fs_component::UP {static_cast( + bt_self_component_get_data(bt_self_component_source_as_self_component(component)))}; } bt2c::GCharUP ctf_fs_make_port_name(struct ctf_fs_ds_file_group *ds_file_group) diff --git a/src/plugins/ctf/fs-src/fs.hpp b/src/plugins/ctf/fs-src/fs.hpp index 530f0fb3..87d649a2 100644 --- a/src/plugins/ctf/fs-src/fs.hpp +++ b/src/plugins/ctf/fs-src/fs.hpp @@ -81,14 +81,9 @@ struct ctf_fs_port_data struct ctf_fs_component *ctf_fs = nullptr; }; -struct ctf_fs_component_deleter -{ - void operator()(ctf_fs_component *); -}; - struct ctf_fs_component { - using UP = std::unique_ptr; + using UP = std::unique_ptr; explicit ctf_fs_component(const bt2c::Logger& parentLogger) noexcept : logger {parentLogger, "PLUGIN/SRC.CTF.FS/COMP"} @@ -181,10 +176,6 @@ int ctf_fs_component_create_ctf_fs_trace(struct ctf_fs_component *ctf_fs, const bt_value *trace_name_value, bt_self_component *selfComp); -/* Free `ctf_fs` and everything it owns. */ - -void ctf_fs_destroy(struct ctf_fs_component *ctf_fs); - /* * Read and validate parameters taken by the src.ctf.fs plugin. * -- 2.34.1