Skip to content

Commit 31b33b8

Browse files
committed
[eclipse-iceoryx#500] Use iox::vector instead of std::array
1 parent 1e8a198 commit 31b33b8

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

iceoryx2-ffi/cxx/include/iox2/unique_port_id.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@
1414
#define IOX2_UNIQUE_PORT_ID_HPP
1515

1616
#include "iox/optional.hpp"
17+
#include "iox/vector.hpp"
1718
#include "iox2/internal/iceoryx2.hpp"
1819

19-
#include <array>
20-
2120
namespace iox2 {
2221

2322
constexpr uint64_t UNIQUE_PORT_ID_LENGTH = 128;
24-
using RawIdType = std::array<uint8_t, UNIQUE_PORT_ID_LENGTH>;
23+
using RawIdType = iox::vector<uint8_t, UNIQUE_PORT_ID_LENGTH>;
2524

2625
/// The system-wide unique id of a [`Publisher`].
2726
class UniquePublisherId {

iceoryx2-ffi/cxx/src/unique_port_id.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ UniquePublisherId::UniquePublisherId(iox2_unique_publisher_id_h handle)
4545

4646
auto UniquePublisherId::bytes() -> iox::optional<RawIdType>& {
4747
if (!m_raw_id.has_value() && m_handle != nullptr) {
48-
RawIdType bytes {};
48+
RawIdType bytes { UNIQUE_PORT_ID_LENGTH, 0 };
4949
iox2_unique_publisher_id_value(m_handle, bytes.data());
5050
m_raw_id.emplace(std::move(bytes));
5151
}
@@ -92,7 +92,7 @@ UniqueSubscriberId::UniqueSubscriberId(iox2_unique_subscriber_id_h handle)
9292

9393
auto UniqueSubscriberId::bytes() -> iox::optional<RawIdType>& {
9494
if (!m_raw_id.has_value() && m_handle != nullptr) {
95-
RawIdType bytes {};
95+
RawIdType bytes { UNIQUE_PORT_ID_LENGTH, 0 };
9696
iox2_unique_subscriber_id_value(m_handle, bytes.data());
9797
m_raw_id.emplace(std::move(bytes));
9898
}
@@ -138,7 +138,7 @@ UniqueNotifierId::UniqueNotifierId(iox2_unique_notifier_id_h handle)
138138

139139
auto UniqueNotifierId::bytes() -> iox::optional<RawIdType>& {
140140
if (!m_raw_id.has_value() && m_handle != nullptr) {
141-
RawIdType bytes {};
141+
RawIdType bytes { UNIQUE_PORT_ID_LENGTH, 0 };
142142
iox2_unique_notifier_id_value(m_handle, bytes.data());
143143
m_raw_id.emplace(std::move(bytes));
144144
}
@@ -184,7 +184,7 @@ UniqueListenerId::UniqueListenerId(iox2_unique_listener_id_h handle)
184184

185185
auto UniqueListenerId::bytes() -> iox::optional<RawIdType>& {
186186
if (!m_raw_id.has_value() && m_handle != nullptr) {
187-
RawIdType bytes {};
187+
RawIdType bytes { UNIQUE_PORT_ID_LENGTH, 0 };
188188
iox2_unique_listener_id_value(m_handle, bytes.data());
189189
m_raw_id.emplace(std::move(bytes));
190190
}

iceoryx2-ffi/cxx/tests/src/unique_port_id_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ struct UniquePortIdTest : public ::testing::Test {
6666
TYPED_TEST_SUITE(UniquePortIdTest, iox2_testing::ServiceTypes);
6767

6868
TYPED_TEST(UniquePortIdTest, unique_port_id_value) {
69-
auto null_id = std::array<uint8_t, iox2::UNIQUE_PORT_ID_LENGTH> {};
69+
auto null_id = iox::vector<uint8_t, iox2::UNIQUE_PORT_ID_LENGTH> {};
7070

7171
auto unique_publisher_id = this->publisher_1.id();
7272
ASSERT_TRUE(unique_publisher_id.bytes().has_value());

0 commit comments

Comments
 (0)