-
Notifications
You must be signed in to change notification settings - Fork 434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get node names and namespaces #545
Conversation
if (ret != RCL_RET_OK) { | ||
auto error_msg = std::string("failed to get node names: ") + rcl_get_error_string_safe(); | ||
rcl_reset_error(); | ||
if (rcutils_string_array_fini(&node_names_c) != RCUTILS_RET_OK) { | ||
error_msg += std::string(", failed also to cleanup node names, leaking memory: ") + | ||
rcl_get_error_string_safe(); | ||
} | ||
if (rcutils_string_array_fini(&node_namespaces_c) != RCUTILS_RET_OK) { | ||
error_msg += std::string(", failed also to cleanup node namespaces, leaking memory: ") + | ||
rcl_get_error_string_safe(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wasn't being done in the existing code either, but you should reset the error with rcl_reset_error()
.
ret = rcutils_string_array_fini(&node_namespaces_c); | ||
if (ret != RCUTILS_RET_OK) { | ||
// *INDENT-OFF* | ||
// TODO(karsten1987): Append rcutils_error_message once it's in master |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really understand this TODO (copied here or from the original) @Karsten1987 can you explain?
@@ -163,10 +183,19 @@ NodeGraph::get_node_names() const | |||
std::string("could not destroy node names: ")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This exception should only be thrown after trying to fini
the node_namespaces_c
struct as well.
|
||
return node_names; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: Seems like unnecessary vertical whitepsace (https://google.github.io/styleguide/cppguide.html#Vertical_Whitespace)
918900c
to
e4a2ee7
Compare
Add a new method to return a vector of pair to get both node names and namespaces.
Connects to ros2/rmw#142