refactor: resolve TODO to use allocator for rmw_request_id_t in Gener…#3146
Closed
Gelminaio wants to merge 1 commit into
Closed
refactor: resolve TODO to use allocator for rmw_request_id_t in Gener…#3146Gelminaio wants to merge 1 commit into
Gelminaio wants to merge 1 commit into
Conversation
…icClient Signed-off-by: Pietro Gelmini <86184562+Gelminaio@users.noreply.github.com>
Collaborator
|
The TODO is just plain wrong. We should not use the C allocator here. |
Collaborator
|
Also, are you sure you did not use AI ? |
Contributor
Author
|
Yeah, you got me 😅. To be completely honest, I used Gemini to help me with the exact syntax for the allocator, since I'm still getting used to the ROS 2 memory management internals. I didn't check the AI box because I thought it was meant for fully written by AI, not just snippets. Completely my bad! Good to know that the TODO is just outdated. I'll close this PR right away. Sorry for the noise! |
Collaborator
|
You can modify the PR to remove the todo though... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Resolves an old TODO in
GenericClient::create_request_header()wherenewwas used to allocate a C-type structure (rmw_request_id_t).This PR replaces the
newoperator withrcutils_get_default_allocator(). It properly allocates the memory usingzero_allocate, checks for allocation failure, and provides a custom deleter to thestd::shared_ptrto deallocate the memory, aligning with ROS 2 memory management best practices.Is this user-facing behavior change?
No
Did you use Generative AI?
No
Additional Information