From: Jérémie Galarneau Date: Fri, 8 Mar 2024 21:17:46 +0000 (-0500) Subject: Move the lttng::free util under the lttng::memory namespace X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=303ac4ed4037e45da1976c0951358ec19c5364d0;p=lttng-tools.git Move the lttng::free util under the lttng::memory namespace Signed-off-by: Jérémie Galarneau Change-Id: I40bf5aefaa8f441f470c0866b71b2957a6c30154 --- diff --git a/include/lttng/session-internal.hpp b/include/lttng/session-internal.hpp index aead01b78..61e65981c 100644 --- a/include/lttng/session-internal.hpp +++ b/include/lttng/session-internal.hpp @@ -22,8 +22,8 @@ struct lttng_session_extended { } LTTNG_PACKED creation_time; } LTTNG_PACKED; -using lttng_session_uptr = - std::unique_ptr::deleter>; +using lttng_session_uptr = std::unique_ptr< + lttng_session[], + lttng::memory::create_deleter_class::deleter>; #endif /* LTTNG_SESSION_INTERNAL_H */ diff --git a/src/bin/lttng-sessiond/rotation-thread.cpp b/src/bin/lttng-sessiond/rotation-thread.cpp index 1d62c851e..a26b38eeb 100644 --- a/src/bin/lttng-sessiond/rotation-thread.cpp +++ b/src/bin/lttng-sessiond/rotation-thread.cpp @@ -68,9 +68,10 @@ struct ls::rotation_thread_timer_queue { namespace { struct rotation_thread_job { - using uptr = std::unique_ptr< - rotation_thread_job, - lttng::memory::create_deleter_class::deleter>; + using uptr = + std::unique_ptr::deleter>; enum ls::rotation_thread_job_type type; struct ltt_session *session; diff --git a/src/bin/lttng-sessiond/ust-app.cpp b/src/bin/lttng-sessiond/ust-app.cpp index 82430db77..12250edfd 100644 --- a/src/bin/lttng-sessiond/ust-app.cpp +++ b/src/bin/lttng-sessiond/ust-app.cpp @@ -6522,7 +6522,8 @@ static int handle_app_register_channel_notification(int sock, struct ust_app_channel *ua_chan; struct ust_app_session *ua_sess; auto ust_ctl_context_fields = - lttng::make_unique_wrapper(raw_context_fields); + lttng::make_unique_wrapper( + raw_context_fields); lttng::urcu::read_lock_guard read_lock_guard; @@ -6686,9 +6687,11 @@ static int add_event_ust_registry(int sock, struct ust_app_channel *ua_chan; struct ust_app_session *ua_sess; lttng::urcu::read_lock_guard rcu_lock; - auto signature = lttng::make_unique_wrapper(raw_signature); - auto fields = lttng::make_unique_wrapper(raw_fields); - auto model_emf_uri = lttng::make_unique_wrapper(raw_model_emf_uri); + auto signature = lttng::make_unique_wrapper(raw_signature); + auto fields = + lttng::make_unique_wrapper(raw_fields); + auto model_emf_uri = + lttng::make_unique_wrapper(raw_model_emf_uri); /* Lookup application. If not found, there is a code flow error. */ app = find_app_by_notify_sock(sock); @@ -6809,8 +6812,9 @@ static int add_enum_ust_registry(int sock, struct ust_app_session *ua_sess; uint64_t enum_id = -1ULL; lttng::urcu::read_lock_guard read_lock_guard; - auto entries = lttng::make_unique_wrapper( - raw_entries); + auto entries = + lttng::make_unique_wrapper( + raw_entries); /* Lookup application. If not found, there is a code flow error. */ app = find_app_by_notify_sock(sock); diff --git a/src/bin/lttng-sessiond/ust-registry-session.cpp b/src/bin/lttng-sessiond/ust-registry-session.cpp index 518108cbd..d0891fe9a 100644 --- a/src/bin/lttng-sessiond/ust-registry-session.cpp +++ b/src/bin/lttng-sessiond/ust-registry-session.cpp @@ -785,8 +785,8 @@ void lsu::registry_session::create_or_find_enum(int session_objd, struct cds_lfht_node *nodep; lsu::registry_enum *reg_enum = nullptr, *old_reg_enum; lttng::urcu::read_lock_guard read_lock_guard; - auto entries = - lttng::make_unique_wrapper(raw_entries); + auto entries = lttng::make_unique_wrapper( + raw_entries); LTTNG_ASSERT(enum_name); diff --git a/src/bin/lttng/commands/destroy.cpp b/src/bin/lttng/commands/destroy.cpp index 0258e31e8..5e19d4189 100644 --- a/src/bin/lttng/commands/destroy.cpp +++ b/src/bin/lttng/commands/destroy.cpp @@ -110,7 +110,8 @@ cmd_error_code destroy_session(const lttng_session& session) } while (ret != 0); } - std::unique_ptr::deleter> + std::unique_ptr::deleter> stats_str; if (!session_was_already_stopped) { char *raw_stats_str = nullptr; @@ -242,7 +243,7 @@ cmd_error_code destroy_session(const lttng_session& session) * destroy the file. */ const auto session_name = - lttng::make_unique_wrapper(get_session_name_quiet()); + lttng::make_unique_wrapper(get_session_name_quiet()); if (session_name && !strncmp(session.name, session_name.get(), NAME_MAX)) { config_destroy_default(); } diff --git a/src/bin/lttng/commands/enable_events.cpp b/src/bin/lttng/commands/enable_events.cpp index f827c924d..b081adeee 100644 --- a/src/bin/lttng/commands/enable_events.cpp +++ b/src/bin/lttng/commands/enable_events.cpp @@ -717,8 +717,9 @@ int enable_events(const std::string& session_name, const event_rule_patterns& pa lttng_dynamic_pointer_array_get_count(&exclusions), (char **) exclusions.array.buffer.data); - auto exclusion_string = lttng::make_unique_wrapper( - print_exclusions(&exclusions)); + auto exclusion_string = + lttng::make_unique_wrapper( + print_exclusions(&exclusions)); if (!exclusion_string) { PERROR("Cannot allocate exclusion_string"); error = 1; @@ -820,8 +821,9 @@ int enable_events(const std::string& session_name, const event_rule_patterns& pa lttng_dynamic_pointer_array_get_count(&exclusions), (char **) exclusions.array.buffer.data); - auto exclusion_string = lttng::make_unique_wrapper( - print_exclusions(&exclusions)); + auto exclusion_string = + lttng::make_unique_wrapper( + print_exclusions(&exclusions)); if (!exclusion_string) { PERROR("Failed allocate exclusion string"); error = 1; @@ -1162,7 +1164,7 @@ int cmd_enable_events(int argc, const char **argv) if (!opt_session_name) { const auto rc_file_session_name = - lttng::make_unique_wrapper(get_session_name()); + lttng::make_unique_wrapper(get_session_name()); if (!rc_file_session_name) { return CMD_ERROR; diff --git a/src/bin/lttng/utils.cpp b/src/bin/lttng/utils.cpp index 26a0cf5ed..403ee0185 100644 --- a/src/bin/lttng/utils.cpp +++ b/src/bin/lttng/utils.cpp @@ -712,7 +712,8 @@ lttng::cli::session_list lttng::cli::list_sessions(const struct session_spec& sp case lttng::cli::session_spec::type::NAME: if (spec.value == nullptr) { const auto configured_name = - lttng::make_unique_wrapper(get_session_name()); + lttng::make_unique_wrapper( + get_session_name()); if (configured_name) { const struct lttng::cli::session_spec new_spec( diff --git a/src/common/format.hpp b/src/common/format.hpp index 07673e7a9..2ba6cef12 100644 --- a/src/common/format.hpp +++ b/src/common/format.hpp @@ -36,9 +36,9 @@ struct formatter : formatter { int status; /* * The documentation of __cxa_demangle mentions the returned string is allocated - * using malloc (not new), hence the use of lttng::free. + * using malloc (not new), hence the use of lttng::memory::free. */ - const auto demangled_name = lttng::make_unique_wrapper( + const auto demangled_name = lttng::make_unique_wrapper( abi::__cxa_demangle(type_info.name(), nullptr, nullptr, &status)); auto it = status == 0 ? formatter::format(demangled_name.get(), ctx) : diff --git a/src/common/make-unique-wrapper.hpp b/src/common/make-unique-wrapper.hpp index ebec2ca45..282181cff 100644 --- a/src/common/make-unique-wrapper.hpp +++ b/src/common/make-unique-wrapper.hpp @@ -53,7 +53,6 @@ struct create_deleter_class { return std::unique_ptr(instance); } }; -} /* namespace memory */ /* * 'free' is a utility function for use with make_unique_wrapper. It makes it easier to @@ -66,6 +65,7 @@ void free(Type *ptr) { std::free(ptr); } +} /* namespace memory */ template std::unique_ptr(raw_tracer_status); + lttng::make_unique_wrapper(raw_tracer_status); if (ask_ret != 4) { return LTTNG_ERR_INVALID;