From 103a02c4a0e4479476c15a5ace84404b13dd3a1d Mon Sep 17 00:00:00 2001 From: Jeff Ithier Date: Wed, 6 Nov 2024 22:15:52 +0100 Subject: [PATCH] [#490] Properly set max slice length consdering custom type settings --- .../cxx/include/iox2/port_factory_publisher.hpp | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/iceoryx2-ffi/cxx/include/iox2/port_factory_publisher.hpp b/iceoryx2-ffi/cxx/include/iox2/port_factory_publisher.hpp index 866084079..9ff5d84f9 100644 --- a/iceoryx2-ffi/cxx/include/iox2/port_factory_publisher.hpp +++ b/iceoryx2-ffi/cxx/include/iox2/port_factory_publisher.hpp @@ -73,18 +73,8 @@ PortFactoryPublisher::create() && -> iox::expected(iox::into(value))); }); m_max_slice_len - .and_then([&](auto value) { - // The payload type used by the C API is always a [u8]. - // Thus need to convert from N to N * sizeof(payload). - // TODO: Consider alignment... not aligning each element properly will impact performance - iox2_port_factory_publisher_builder_set_max_slice_len( - &m_handle, value * sizeof(typename PayloadInfo::ValueType)); - }) - .or_else([&]() { - // Assume only one element if not otherwise specified - iox2_port_factory_publisher_builder_set_max_slice_len(&m_handle, - sizeof(typename PayloadInfo::ValueType)); - }); + .and_then([&](auto value) { iox2_port_factory_publisher_builder_set_max_slice_len(&m_handle, value); }) + .or_else([&]() { iox2_port_factory_publisher_builder_set_max_slice_len(&m_handle, 1); }); m_max_loaned_samples.and_then( [&](auto value) { iox2_port_factory_publisher_builder_set_max_loaned_samples(&m_handle, value); });