Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reset wait_set type index in SET_RESIZE #207

Merged
merged 1 commit into from
Jan 19, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions rcl/src/rcl/wait.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ rcl_wait_set_get_allocator(const rcl_wait_set_t * wait_set, rcl_allocator_t * al
} \
rcl_allocator_t allocator = wait_set->impl->allocator; \
wait_set->size_of_ ## Type ## s = 0; \
wait_set->impl->Type ## _index = 0; \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be set to the min() of the requested size and the wait_set->impl->Type ## _index? Otherwise this is also like a "clear" which is not the intention I think. If the size before was 4 and the index was 2, then the resize was to be 8, the index should still be 2 right?

Copy link
Contributor Author

@jwang11 jwang11 Jan 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look at the realloc code after that, it actually clear the new allocated memory. So, I think the old index is meaningless. If people want old index value, he should save it out before SET_RESIZE.

  memset((void *)wait_set->Type ## s, 0, sizeof(rcl_ ## Type ## _t *) * size); \
  wait_set->size_of_ ## Type ## s = size; \

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, it does zero the memory. 👍

if (size == 0) { \
if (wait_set->Type ## s) { \
allocator.deallocate((void *)wait_set->Type ## s, allocator.state); \
Expand Down