Skip to content

Fixes memory leaks for nested fields#7

Merged
dirk-thomas merged 2 commits intoros2:masterfrom
martins-mozeiko:fix-memory-leaks
Jul 12, 2018
Merged

Fixes memory leaks for nested fields#7
dirk-thomas merged 2 commits intoros2:masterfrom
martins-mozeiko:fix-memory-leaks

Conversation

@martins-mozeiko
Copy link
Copy Markdown
Contributor

@martins-mozeiko martins-mozeiko commented Jul 11, 2018

This separates memory allocation out from convert_from_py function. Now it uses separate create_message function to allocate message, making it explicit gives better control where and how memory is allocated and freed.

See #5 for details.

This separates memory allocation out from convert_from_py function.
Now it uses separate create_message function to allocate message,
making it explicit gives better control where and how memory is
allocated and freed.
@dirk-thomas dirk-thomas added the in review Waiting for review (Kanban column) label Jul 11, 2018
return NULL;
return false;
}
if (!@(nested_type)__Array__init(&(ros_message->@(field.name)), size)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Still wrapping my head around the message generation code. What checks that ros_message is not NULL before this point?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In current code caller checks in _rclpy.c after it allocated it with create_ros_message. I can add explicit check here, but current code already was not checking any other arguments like _pymsg or raw_ros_message, so I did not add any extra checks for this new argument.

@mikaelarguedas mikaelarguedas mentioned this pull request Jul 12, 2018
13 tasks
@dirk-thomas dirk-thomas merged commit feabdce into ros2:master Jul 12, 2018
@dirk-thomas dirk-thomas removed the in review Waiting for review (Kanban column) label Jul 12, 2018
@martins-mozeiko martins-mozeiko deleted the fix-memory-leaks branch August 3, 2018 01:39
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