Skip to content
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

expose list of nodes #88

Merged
merged 2 commits into from
Jan 30, 2017
Merged

expose list of nodes #88

merged 2 commits into from
Jan 30, 2017

Conversation

Karsten1987
Copy link
Contributor

@Karsten1987 Karsten1987 commented Jan 26, 2017

Connect to ros2/cli_tools#1

@Karsten1987 Karsten1987 added the in review Waiting for review (Kanban column) label Jan 26, 2017
@Karsten1987 Karsten1987 self-assigned this Jan 26, 2017
@jacquelinekay jacquelinekay added the in progress Actively being worked on (Kanban column) label Jan 26, 2017
@dirk-thomas dirk-thomas removed the in progress Actively being worked on (Kanban column) label Jan 26, 2017
for (size_t i = 0; i < name_count; i++) {
rmw_free(node_names->names[i]);
}
rmw_free(node_names->names);
Copy link
Member

Choose a reason for hiding this comment

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

This should set the values back to nullptr / 0 before deallocation (same as it is done for Connext).

rmw_node_names_t * node_names)
{
size_t name_count = node_names->node_count;
for (size_t i = 0; i < name_count; i++) {
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick: ++i

node_names->node_count = participant_names.size();
node_names->names = static_cast<char **>(rmw_allocate(node_names->node_count * sizeof(char *)));
for (size_t i = 0; i < participant_names.size(); ++i) {
node_names->names[i] = __local_strdup(participant_names[i].c_str());
Copy link
Member

Choose a reason for hiding this comment

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

It seems that the __local_strdup function bypasses the rmw allocator.

Copy link
Contributor Author

@Karsten1987 Karsten1987 Jan 26, 2017

Choose a reason for hiding this comment

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

not sure I understand.
Should we replace strdup with rmw_allocate... and memcpy/strcpy ?

Copy link
Member

Choose a reason for hiding this comment

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

The assumption is that rmw_allocate should be able to provide a custom strategy (e.g. use memory from a preallocated pool to avoid any allocation at runtime). If any code directly allocates memory (like strdup does) it undermines that approach. E.g. this would immediately break any attempt to achieve realtime.

Therefore, yes, I think this should use rmw_allocate and memcpy.

@Karsten1987 Karsten1987 merged commit 266e693 into master Jan 30, 2017
@Karsten1987 Karsten1987 deleted the rosnode_list branch January 30, 2017 18:29
@Karsten1987 Karsten1987 removed the in review Waiting for review (Kanban column) label Jan 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants