Skip to content

Commit

Permalink
Tweaks to client.c and subscription.c for cleaner init/fini
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Brawner <brawner@gmail.com>
  • Loading branch information
brawner committed Jul 29, 2020
1 parent af438bc commit 645138b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions rcl/src/rcl/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,9 @@ rcl_client_fini(rcl_client_t * client, rcl_node_t * node)
RCL_SET_ERROR_MSG(rmw_get_error_string().str);
result = RCL_RET_ERROR;
}

allocator.deallocate(client->impl, allocator.state);
client->impl = NULL;
}
RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME, "Client finalized");
return result;
Expand Down
3 changes: 3 additions & 0 deletions rcl/src/rcl/subscription.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ rcl_subscription_init(
RCL_CHECK_FOR_NULL_WITH_MSG(
subscription->impl, "allocating memory failed", ret = RCL_RET_BAD_ALLOC; goto cleanup);
// Fill out the implemenation struct.

// rmw_handle
// TODO(wjwwood): pass allocator once supported in rmw api.
subscription->impl->rmw_handle = rmw_create_subscription(
Expand Down Expand Up @@ -194,6 +195,7 @@ rcl_subscription_init(
fail:
if (subscription->impl) {
allocator->deallocate(subscription->impl, allocator->state);
subscription->impl = NULL;
}
ret = fail_ret;
// Fall through to cleanup
Expand Down Expand Up @@ -229,6 +231,7 @@ rcl_subscription_fini(rcl_subscription_t * subscription, rcl_node_t * node)
result = RCL_RET_ERROR;
}
allocator.deallocate(subscription->impl, allocator.state);
subscription->impl = NULL;
}
RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME, "Subscription finalized");
return result;
Expand Down

0 comments on commit 645138b

Please sign in to comment.