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

Is documentation for reallocate consistent? #47

Closed
jacquelinekay opened this issue Apr 19, 2016 · 3 comments
Closed

Is documentation for reallocate consistent? #47

jacquelinekay opened this issue Apr 19, 2016 · 3 comments

Comments

@jacquelinekay
Copy link
Contributor

https://github.com/ros2/rcl/blob/master/rcl/include/rcl/allocator.h#L45-L52

The comment for "reallocate" implies to me that if the field is left null, then a reallocate function will be constructed from "deallocate" and "allocate". I wasn't sure where in the implementation this actually happens though; it seems as if realloc will simply throw an error in this case.

https://github.com/ros2/rcl/blob/master/rcl/src/rcl/allocator.c#L54-L64

There are also several places were an error is returned in reallocate is null, e.g. https://github.com/ros2/rcl/blob/master/rcl/src/rcl/wait.c#L126-L127

It's not an issue in terms of what's needed in the implementation, but we should take a moment to make sure implementation and documentation are consistent.

@wjwwood
Copy link
Member

wjwwood commented Apr 21, 2016

https://github.com/ros2/rcl/blob/master/rcl/include/rcl/allocator.h#L45-L52

This linked comment doesn't mention that realloc can be a null function. I think the meaning (of this comment) is that any function pointed to from here should do the realloc behavior if possible, but if not it should alloc and then dealloc if successful.

There are also several places were an error is returned in reallocate is null, e.g. https://github.com/ros2/rcl/blob/master/rcl/src/rcl/wait.c#L126-L127

That needs realloc to be set, because it just wraps it and deallocates the input pointer even if the alloc fails, i.e. the behavior of reallocf.

So I don't think it's out of step, but maybe I'm reading it differently than you. Is there a clearer statement which indicates that the realloc pointer should not be null?

@jacquelinekay
Copy link
Contributor Author

Maybe it was just wishful thinking on my part.

As a side note, since realloc is not provided in std::allocator_traits, I created realloc from dealloc and alloc in rclcpp. Unfortunately my approach didn't work on Windows (caused a segfault in every rclcpp test). I've thrown up my hands in despair and ifdef'd out custom allocators in Windows so that the use_rcl branch can get merged:

ros2/rclcpp@c1fc16e#diff-43afa33f042770415fd58f1b74c20fcdR72

But my next step will probably be to play around with realloc on Windows to see if we can make it work and if API changes will need to be made to rcl.

@wjwwood
Copy link
Member

wjwwood commented Apr 21, 2016

Ok, well unless you think we should change it, can you close the issue?

emersonknapp pushed a commit to aws-ros-dev/rcl that referenced this issue Jun 3, 2019
ivanpauno pushed a commit that referenced this issue Jan 2, 2020
…y_set

only persist the rmw impl if it was explicitly set
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

No branches or pull requests

2 participants