Add fix for resize to zero bug with test
This commit is contained in:
parent
2749c08f60
commit
2ebc7d71c4
2 changed files with 16 additions and 1 deletions
|
@ -293,6 +293,7 @@ rcl_wait_set_get_allocator(const rcl_wait_set_t * wait_set, rcl_allocator_t * al
|
|||
return RCL_RET_OK; \
|
||||
} \
|
||||
rcl_allocator_t allocator = wait_set->impl->allocator; \
|
||||
wait_set->size_of_ ## Type ## s = 0; \
|
||||
if (size == 0) { \
|
||||
if (wait_set->Type ## s) { \
|
||||
allocator.deallocate((void *)wait_set->Type ## s, allocator.state); \
|
||||
|
@ -300,7 +301,6 @@ rcl_wait_set_get_allocator(const rcl_wait_set_t * wait_set, rcl_allocator_t * al
|
|||
} \
|
||||
ExtraDealloc \
|
||||
} else { \
|
||||
wait_set->size_of_ ## Type ## s = 0; \
|
||||
wait_set->Type ## s = (const rcl_ ## Type ## _t * *)allocator.reallocate( \
|
||||
(void *)wait_set->Type ## s, sizeof(rcl_ ## Type ## _t *) * size, allocator.state); \
|
||||
RCL_CHECK_FOR_NULL_WITH_MSG( \
|
||||
|
|
|
@ -41,3 +41,18 @@ TEST(CLASSNAME(WaitSetTestFixture, RMW_IMPLEMENTATION), test_resize_to_zero) {
|
|||
ret = rcl_wait_set_fini(&wait_set);
|
||||
ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
|
||||
}
|
||||
|
||||
TEST(CLASSNAME(WaitSetTestFixture, RMW_IMPLEMENTATION), test_clear) {
|
||||
// Initialize a waitset with a subscription and then resize it to zero.
|
||||
rcl_wait_set_t wait_set = rcl_get_zero_initialized_wait_set();
|
||||
rcl_ret_t ret = rcl_wait_set_init(&wait_set, 1, 0, 0, 0, 0, rcl_get_default_allocator());
|
||||
ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
|
||||
|
||||
ret = rcl_wait_set_clear_subscriptions(&wait_set);
|
||||
ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
|
||||
|
||||
EXPECT_EQ(wait_set.size_of_subscriptions, 0);
|
||||
|
||||
ret = rcl_wait_set_fini(&wait_set);
|
||||
ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue