Skip to content
This repository was archived by the owner on Oct 7, 2021. It is now read-only.

update to support new rmw API with namespaces #164

Merged
merged 1 commit into from
Apr 8, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion rmw_opensplice_cpp/src/rmw_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,16 @@
extern "C"
{
rmw_node_t *
rmw_create_node(const char * name, size_t domain_id)
rmw_create_node(const char * name, const char * namespace_, size_t domain_id)
{
if (!name) {
RMW_SET_ERROR_MSG("name is null");
return nullptr;
}
if (!namespace_) {
RMW_SET_ERROR_MSG("namespace_ is null");
return nullptr;
}
DDS::DomainParticipantFactory_var dp_factory = DDS::DomainParticipantFactory::get_instance();
if (!dp_factory) {
RMW_SET_ERROR_MSG("failed to get domain participant factory");
Expand Down Expand Up @@ -202,6 +206,13 @@ rmw_create_node(const char * name, size_t domain_id)
}
memcpy(const_cast<char *>(node->name), name, strlen(name) + 1);

node->namespace_ = reinterpret_cast<const char *>(rmw_allocate(sizeof(char) * strlen(namespace_) + 1));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This memory is never freed. See #194.

if (!node->namespace_) {
RMW_SET_ERROR_MSG("failed to allocate memory for node namespace");
goto fail;
}
memcpy(const_cast<char *>(node->namespace_), namespace_, strlen(namespace_) + 1);

buf = rmw_allocate(sizeof(OpenSpliceStaticNodeInfo));
if (!buf) {
RMW_SET_ERROR_MSG("failed to allocate memory");
Expand Down