From 9d57305d09cd371677edf065a38c2af527908bcd Mon Sep 17 00:00:00 2001 From: Mahmoud Mazouz Date: Mon, 25 Nov 2024 17:47:15 +0100 Subject: [PATCH] Fix `z_view_string_t` to `std::string` conversion --- rmw_zenoh_cpp/src/detail/rmw_service_data.cpp | 5 +++-- rmw_zenoh_cpp/src/detail/rmw_subscription_data.cpp | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/rmw_zenoh_cpp/src/detail/rmw_service_data.cpp b/rmw_zenoh_cpp/src/detail/rmw_service_data.cpp index b51b3973..7eab62d9 100644 --- a/rmw_zenoh_cpp/src/detail/rmw_service_data.cpp +++ b/rmw_zenoh_cpp/src/detail/rmw_service_data.cpp @@ -46,8 +46,9 @@ void service_data_handler(z_loaned_query_t * query, void * data) RMW_ZENOH_LOG_ERROR_NAMED( "rmw_zenoh_cpp", "Unable to obtain ServiceData from data for " - "service for %s", - z_loan(keystr) + "service for %.*s", + static_cast(z_string_len(z_loan(keystr))), + z_string_data(z_loan(keystr)) ); return; } diff --git a/rmw_zenoh_cpp/src/detail/rmw_subscription_data.cpp b/rmw_zenoh_cpp/src/detail/rmw_subscription_data.cpp index 614288f6..ed0a97fc 100644 --- a/rmw_zenoh_cpp/src/detail/rmw_subscription_data.cpp +++ b/rmw_zenoh_cpp/src/detail/rmw_subscription_data.cpp @@ -65,12 +65,14 @@ void sub_data_handler(z_loaned_sample_t * sample, void * data) z_owned_slice_t slice; z_bytes_to_slice(payload, &slice); + std::string topic_name(z_string_data(z_loan(keystr)), z_string_len(z_loan(keystr))); + sub_data->add_new_message( std::make_unique( slice, z_timestamp_ntp64_time(z_sample_timestamp(sample)), std::move(attachment)), - z_string_data(z_loan(keystr))); + &topic_name); } } // namespace