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

Fixes memory leaks for nested fields #7

Merged
merged 2 commits into from
Jul 12, 2018
Merged

Fixes memory leaks for nested fields #7

merged 2 commits into from
Jul 12, 2018

Conversation

martins-mozeiko
Copy link
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
}
@[ if field.type.array_size is None or field.type.is_upper_bound]@
Py_ssize_t size = PySequence_Size(field);
if (-1 == size) {
Py_DECREF(seq_field);
Py_DECREF(field);
return NULL;
return false;
}
if (!@(nested_type)__Array__init(&(ros_message->@(field.name)), size)) {
Copy link
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
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.

None yet

3 participants