From 52863d03222841acb3002cc2f1db7302a95bb4bd Mon Sep 17 00:00:00 2001 From: Christian Eltzschig Date: Thu, 5 Dec 2024 16:30:11 +0100 Subject: [PATCH] [#532] Add debug_assert and fix C++ docu --- examples/cxx/publish_subscribe_dynamic_data/README.md | 6 +++--- iceoryx2/src/port/publisher.rs | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/cxx/publish_subscribe_dynamic_data/README.md b/examples/cxx/publish_subscribe_dynamic_data/README.md index 79548170e..9e1a96fcd 100644 --- a/examples/cxx/publish_subscribe_dynamic_data/README.md +++ b/examples/cxx/publish_subscribe_dynamic_data/README.md @@ -15,9 +15,9 @@ allowing users to send samples of arbitrary sizes. > * have a uniform memory representation -> `#[repr(C)]` > * not use pointers to manage their internal structure > -> Data types like `String` or `Vec` will cause undefined behavior and may -> result in segmentation faults. We provide alternative data types that are -> compatible with shared memory. See the +> Data types like `std::string` or `std::vector` will cause undefined behavior +> and may result in segmentation faults. We provide alternative data types +> that are compatible with shared memory. See the > [complex data type example](../complex_data_types) for guidance on how to > use them. diff --git a/iceoryx2/src/port/publisher.rs b/iceoryx2/src/port/publisher.rs index 0d4e831a6..b0703da32 100644 --- a/iceoryx2/src/port/publisher.rs +++ b/iceoryx2/src/port/publisher.rs @@ -261,6 +261,7 @@ impl SegmentState { } fn sample_index(&self, distance_to_chunk: usize) -> usize { + debug_assert!(distance_to_chunk % self.payload_size() == 0); distance_to_chunk / self.payload_size() }