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

Dynamic Subscription (BONUS: Allocators): rosidl_dynamic_typesupport_fastrtps #3

Merged
merged 3 commits into from
Apr 11, 2023

Conversation

methylDragon
Copy link
Collaborator

Signed-off-by: methylDragon <methylDragon@gmail.com>
Signed-off-by: methylDragon <methylDragon@gmail.com>
Signed-off-by: methylDragon <methylDragon@gmail.com>
@methylDragon methylDragon force-pushed the runtime_interface_reflection_allocators branch from 6c9c5b2 to f5f1b30 Compare April 10, 2023 20:07
@@ -444,7 +449,7 @@ fastrtps__dynamic_data_get_string_value(
);

*value_length = tmp_string.size();
char * tmp_out = new char[*value_length + 1];
char * tmp_out = new char[*value_length + 1]; // TODO(methylDragon): Use alloc here
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure which alloc you are referring to here. Can you be more specific? I would think we would need to pass in an allocator and use that, but I'm not sure.

Further, we need to check for allocation failure here. Either we need to specify nothrow and check for NULL, or capture the exception (which won't be able to bubble through the C layer that calls into this).

Same goes a few times below.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Just the new, yeah.. Because the caller will be in charge of destroying the obtained buffer

I was thinking it'd be good if they did it using the allocator stored in the data_impl, but because it was an implementation detail, I didn't want to get to it yet

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This one I will defer for now (hence the TODO)

*type_builder_impl = new rosidl_dynamic_typesupport_dynamic_type_builder_impl_t{
std::move(type_builder_handle)};

type_builder_impl->handle = std::move(type_builder_handle);
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think the std::move does anything here, right? These are both just pointers. For that matter, you could probably just do type_builder_impl->handle = fastrtps_impl->type_factory_->create_struct_builder(); above, though maybe C++ would warn about assigning a DynamicTypeBuilder * to a void *, I'm not sure.

Same question a few times below.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, that's true.. I just thought it was more explicit, stylistically, but I can just do an assignment without the move?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, that's true.. I just thought it was more explicit, stylistically, but I can just do an assignment without the move?

When I see a std::move, I'm looking for the transfer of ownership, which I guess is happening in principle, but not by the C++ rules. For a pointer assignment, I think just the direct assignment would be better, yeah.

Copy link
Collaborator Author

@methylDragon methylDragon Apr 10, 2023

Choose a reason for hiding this comment

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

Okay, I will edit

Edit: Should we defer this till after the merge?

@methylDragon methylDragon merged commit 081a532 into rolling Apr 11, 2023
@delete-merged-branch delete-merged-branch bot deleted the runtime_interface_reflection_allocators branch April 11, 2023 06:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants