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:
parent
6d13bcb0fc
commit
3e0fa4be66
2 changed files with 4 additions and 8 deletions
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue