deallocate state and transition handles after call to fini (#424)

* deallocate state and transition handles after call to fini

* deallocate also when error occured
This commit is contained in:
Karsten Knese 2017-12-06 17:26:18 -08:00 committed by GitHub
parent 6d13bcb0fc
commit 3e0fa4be66
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 8 deletions

View file

@ -153,11 +153,9 @@ State::reset()
return; return;
} }
// TODO(karsten1987): Fini currently deallocate the state_handle_ instance as well
// this should be changed to only deallocate members of the pointer so that stack
// variables can be correctly used as well.
// see https://github.com/ros2/rclcpp/pull/419#discussion_r155157098
auto ret = rcl_lifecycle_state_fini(state_handle_, &allocator_); auto ret = rcl_lifecycle_state_fini(state_handle_, &allocator_);
allocator_.deallocate(state_handle_, allocator_.state);
state_handle_ = nullptr;
if (ret != RCL_RET_OK) { if (ret != RCL_RET_OK) {
rclcpp::exceptions::throw_from_rcl_error(ret); rclcpp::exceptions::throw_from_rcl_error(ret);
} }

View file

@ -257,11 +257,9 @@ Transition::reset()
return; return;
} }
// TODO(karsten1987): Fini currently deallocate the transition_handle_ instance as well
// this should be changed to only deallocate members of the pointer so that stack
// variables can be correctly used as well.
// see https://github.com/ros2/rclcpp/pull/419#discussion_r155157098
auto ret = rcl_lifecycle_transition_fini(transition_handle_, &allocator_); auto ret = rcl_lifecycle_transition_fini(transition_handle_, &allocator_);
allocator_.deallocate(transition_handle_, allocator_.state);
transition_handle_ = nullptr;
if (ret != RCL_RET_OK) { if (ret != RCL_RET_OK) {
rclcpp::exceptions::throw_from_rcl_error(ret); rclcpp::exceptions::throw_from_rcl_error(ret);
} }