-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Modernise manual memory management in range_image_border_extractor
#3865
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
base: master
Are you sure you want to change the base?
Modernise manual memory management in range_image_border_extractor
#3865
Conversation
@shrijitsingh99 Are you working on this or should we consider this ready for review? |
Still working on it though would require some feedback, since haven't used smart pointers extensively. |
ee3018b
to
d15f4f2
Compare
Marking this as stale due to 30 days of inactivity. Commenting or adding a new commit to the pull request will revert this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Partial, more on the implementation, not the methodology
@@ -0,0 +1,101 @@ | |||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Save 40 lines using SPDX license
delete[] surface_change_directions_; | ||
surface_change_directions_ = blurred_directions; | ||
delete[] surface_change_scores_; | ||
surface_change_directions_.reset(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Swap and reset instead?
delete[] surface_change_scores_; | ||
surface_change_directions_.reset(); | ||
surface_change_directions_ = std::unique_ptr<Eigen::Vector3f[]>(std::move(blurred_directions)); | ||
surface_change_scores_.clear(); | ||
surface_change_scores_ = blurred_scores; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::move
here
delete[] surface_change_scores_; | ||
surface_change_directions_.reset(); | ||
surface_change_directions_ = std::unique_ptr<Eigen::Vector3f[]>(std::move(blurred_directions)); | ||
surface_change_scores_.clear(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to clear
One comment before the review, the current implementation which adds unique_ptr, creates a potential API breakage by disabling copy operations in this class. |
That implies existing implementation has a potential double free bug, right? Can be resolved by adding a custom copy op. (Still breaks ABI) |
Marking this as stale due to 30 days of inactivity. Commenting or adding a new commit to the pull request will revert this. |
Solves #3801