From 645138b3542e6300c9b160e086f2840bb094841d Mon Sep 17 00:00:00 2001 From: Stephen Brawner Date: Tue, 28 Jul 2020 17:22:51 -0700 Subject: [PATCH] Tweaks to client.c and subscription.c for cleaner init/fini Signed-off-by: Stephen Brawner --- rcl/src/rcl/client.c | 2 ++ rcl/src/rcl/subscription.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/rcl/src/rcl/client.c b/rcl/src/rcl/client.c index 9bf70dc4a..2854e6126 100644 --- a/rcl/src/rcl/client.c +++ b/rcl/src/rcl/client.c @@ -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; diff --git a/rcl/src/rcl/subscription.c b/rcl/src/rcl/subscription.c index 2e3b37d38..b5b644621 100644 --- a/rcl/src/rcl/subscription.c +++ b/rcl/src/rcl/subscription.c @@ -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( @@ -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 @@ -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;