diff --git a/test/dds/xtypes/TypeLookupServicePublisher.cpp b/test/dds/xtypes/TypeLookupServicePublisher.cpp index f6649d8dc1e..31d792d941d 100644 --- a/test/dds/xtypes/TypeLookupServicePublisher.cpp +++ b/test/dds/xtypes/TypeLookupServicePublisher.cpp @@ -139,7 +139,7 @@ bool TypeLookupServicePublisher::create_known_type_impl( { // Create a new PubKnownType for the given type PubKnownType a_type; - a_type.type_ = new Type(); + a_type.type_.reset(new Type()); a_type.type_sup_.reset(new TypePubSubType()); a_type.type_sup_.register_type(participant_); diff --git a/test/dds/xtypes/TypeLookupServicePublisher.h b/test/dds/xtypes/TypeLookupServicePublisher.h index ee60429d743..921facdcc90 100644 --- a/test/dds/xtypes/TypeLookupServicePublisher.h +++ b/test/dds/xtypes/TypeLookupServicePublisher.h @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -50,7 +51,7 @@ namespace dds { struct PubKnownType { - void* type_ {nullptr}; + std::shared_ptr type_; DynamicType::_ref_type dyn_type_; TypeSupport type_sup_; diff --git a/test/dds/xtypes/TypeLookupServiceSubscriber.cpp b/test/dds/xtypes/TypeLookupServiceSubscriber.cpp index 83e6b8b6540..cd2d8e4b4a8 100644 --- a/test/dds/xtypes/TypeLookupServiceSubscriber.cpp +++ b/test/dds/xtypes/TypeLookupServiceSubscriber.cpp @@ -145,7 +145,7 @@ bool TypeLookupServiceSubscriber::create_known_type_impl( { // Create a new SubKnownType for the given type SubKnownType a_type; - a_type.type_ = new Type(); + a_type.type_.reset(new Type()); a_type.type_sup_.reset(new TypePubSubType()); a_type.type_sup_.register_type(participant_); diff --git a/test/dds/xtypes/TypeLookupServiceSubscriber.h b/test/dds/xtypes/TypeLookupServiceSubscriber.h index 3b9799f34cd..61c65cd238b 100644 --- a/test/dds/xtypes/TypeLookupServiceSubscriber.h +++ b/test/dds/xtypes/TypeLookupServiceSubscriber.h @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -51,7 +52,7 @@ namespace dds { struct SubKnownType { - void* type_ {nullptr}; + std::shared_ptr type_; DynamicType::_ref_type dyn_type_; TypeSupport type_sup_; }; diff --git a/test/unittest/dds/xtypes/type_lookup_service/TypeLookupServiceTests.cpp b/test/unittest/dds/xtypes/type_lookup_service/TypeLookupServiceTests.cpp index 9553db550e8..acce49daf0c 100644 --- a/test/unittest/dds/xtypes/type_lookup_service/TypeLookupServiceTests.cpp +++ b/test/unittest/dds/xtypes/type_lookup_service/TypeLookupServiceTests.cpp @@ -461,7 +461,7 @@ TEST_F(TypeLookupServiceTests, TypeLookupReplyListener_wrong_EntityId) TEST_F(TypeLookupServiceTests, TypeLookupReplyListener_malformed_Reply) { - CacheChange_t* change = new CacheChange_t(); + CacheChange_t* change {new CacheChange_t()}; change->writerGUID.entityId = c_EntityId_TypeLookup_reply_writer; EXPECT_CALL(*tlm_, receive( @@ -484,9 +484,9 @@ TEST_F(TypeLookupServiceTests, TypeLookupReplyListener_REMOTE_EX_UNSUPPORTED) std::to_string(static_cast(rpc::RemoteExceptionCode_t::REMOTE_EX_UNSUPPORTED))); - CacheChange_t* change = new CacheChange_t(); - change->writerGUID.entityId = c_EntityId_TypeLookup_reply_writer; - stateful_reader_.get_history()->add_change(change); + CacheChange_t change; + change.writerGUID.entityId = c_EntityId_TypeLookup_reply_writer; + stateful_reader_.get_history()->add_change(&change); TypeLookup_Reply expectedReply; expectedReply.header().remoteEx(rpc::RemoteExceptionCode_t::REMOTE_EX_UNSUPPORTED); @@ -495,7 +495,7 @@ TEST_F(TypeLookupServiceTests, TypeLookupReplyListener_REMOTE_EX_UNSUPPORTED) testing::Matcher(_))) .WillOnce(testing::DoAll(testing::SetArgReferee<1>(expectedReply), testing::Return(true))); - reply_listener_->on_new_cache_change_added(&stateful_reader_, change); + reply_listener_->on_new_cache_change_added(&stateful_reader_, &change); EXPECT_EQ(reply_listener_->get_replies_queue()->size(), 0); @@ -511,9 +511,9 @@ TEST_F(TypeLookupServiceTests, TypeLookupReplyListener_REMOTE_EX_INVALID_ARGUMEN std::to_string(static_cast(rpc::RemoteExceptionCode_t::REMOTE_EX_INVALID_ARGUMENT))); - CacheChange_t* change = new CacheChange_t(); - change->writerGUID.entityId = c_EntityId_TypeLookup_reply_writer; - stateful_reader_.get_history()->add_change(change); + CacheChange_t change; + change.writerGUID.entityId = c_EntityId_TypeLookup_reply_writer; + stateful_reader_.get_history()->add_change(&change); TypeLookup_Reply expectedReply; expectedReply.header().remoteEx(rpc::RemoteExceptionCode_t::REMOTE_EX_INVALID_ARGUMENT); @@ -522,7 +522,7 @@ TEST_F(TypeLookupServiceTests, TypeLookupReplyListener_REMOTE_EX_INVALID_ARGUMEN testing::Matcher(_))) .WillOnce(testing::DoAll(testing::SetArgReferee<1>(expectedReply), testing::Return(true))); - reply_listener_->on_new_cache_change_added(&stateful_reader_, change); + reply_listener_->on_new_cache_change_added(&stateful_reader_, &change); EXPECT_EQ(reply_listener_->get_replies_queue()->size(), 0); @@ -538,9 +538,9 @@ TEST_F(TypeLookupServiceTests, TypeLookupReplyListener_REMOTE_EX_OUT_OF_RESOURCE std::to_string(static_cast(rpc::RemoteExceptionCode_t::REMOTE_EX_OUT_OF_RESOURCES))); - CacheChange_t* change = new CacheChange_t(); - change->writerGUID.entityId = c_EntityId_TypeLookup_reply_writer; - stateful_reader_.get_history()->add_change(change); + CacheChange_t change; + change.writerGUID.entityId = c_EntityId_TypeLookup_reply_writer; + stateful_reader_.get_history()->add_change(&change); TypeLookup_Reply expectedReply; expectedReply.header().remoteEx(rpc::RemoteExceptionCode_t::REMOTE_EX_OUT_OF_RESOURCES); @@ -549,7 +549,7 @@ TEST_F(TypeLookupServiceTests, TypeLookupReplyListener_REMOTE_EX_OUT_OF_RESOURCE testing::Matcher(_))) .WillOnce(testing::DoAll(testing::SetArgReferee<1>(expectedReply), testing::Return(true))); - reply_listener_->on_new_cache_change_added(&stateful_reader_, change); + reply_listener_->on_new_cache_change_added(&stateful_reader_, &change); EXPECT_EQ(reply_listener_->get_replies_queue()->size(), 0); Log::Flush(); @@ -564,9 +564,9 @@ TEST_F(TypeLookupServiceTests, TypeLookupReplyListener_REMOTE_EX_UNKNOWN_OPERATI std::to_string(static_cast(rpc::RemoteExceptionCode_t::REMOTE_EX_UNKNOWN_OPERATION))); - CacheChange_t* change = new CacheChange_t(); - change->writerGUID.entityId = c_EntityId_TypeLookup_reply_writer; - stateful_reader_.get_history()->add_change(change); + CacheChange_t change; + change.writerGUID.entityId = c_EntityId_TypeLookup_reply_writer; + stateful_reader_.get_history()->add_change(&change); TypeLookup_Reply expectedReply; expectedReply.header().remoteEx(rpc::RemoteExceptionCode_t::REMOTE_EX_UNKNOWN_OPERATION); @@ -575,7 +575,7 @@ TEST_F(TypeLookupServiceTests, TypeLookupReplyListener_REMOTE_EX_UNKNOWN_OPERATI testing::Matcher(_))) .WillOnce(testing::DoAll(testing::SetArgReferee<1>(expectedReply), testing::Return(true))); - reply_listener_->on_new_cache_change_added(&stateful_reader_, change); + reply_listener_->on_new_cache_change_added(&stateful_reader_, &change); EXPECT_EQ(reply_listener_->get_replies_queue()->size(), 0); Log::Flush(); @@ -590,9 +590,9 @@ TEST_F(TypeLookupServiceTests, TypeLookupReplyListener_REMOTE_EX_UNKNOWN_EXCEPTI std::to_string(static_cast(rpc::RemoteExceptionCode_t::REMOTE_EX_UNKNOWN_EXCEPTION))); - CacheChange_t* change = new CacheChange_t(); - change->writerGUID.entityId = c_EntityId_TypeLookup_reply_writer; - stateful_reader_.get_history()->add_change(change); + CacheChange_t change; + change.writerGUID.entityId = c_EntityId_TypeLookup_reply_writer; + stateful_reader_.get_history()->add_change(&change); TypeLookup_Reply expectedReply; expectedReply.header().remoteEx(rpc::RemoteExceptionCode_t::REMOTE_EX_UNKNOWN_EXCEPTION); @@ -601,7 +601,7 @@ TEST_F(TypeLookupServiceTests, TypeLookupReplyListener_REMOTE_EX_UNKNOWN_EXCEPTI testing::Matcher(_))) .WillOnce(testing::DoAll(testing::SetArgReferee<1>(expectedReply), testing::Return(true))); - reply_listener_->on_new_cache_change_added(&stateful_reader_, change); + reply_listener_->on_new_cache_change_added(&stateful_reader_, &change); EXPECT_EQ(reply_listener_->get_replies_queue()->size(), 0); Log::Flush();