-
Notifications
You must be signed in to change notification settings - Fork 1
Non-copy vector #14
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
Comments
Details: Modify all the Lines 16 to 22 in 7bd81ec
could be rewritten to be: inline VecPoint vecpoint_cpp2c(std::vector<cv::Point> v) {
return VecPoint {.ptr = v.data(), .length = v.size() };
} Most important thing here is testing. Research shows that vector data should not be changed or overwritten or de-allocated so long as the vector is not modified. That means this would be very bad: vector<cv::Point> vec;
// fill in vec here
auto result = vecpoint_cpp2c(vec);
vec.push(newPoint);
// THIS SHOULD NO LONGER BE USED!
// Adding new elements can change the internal memory structure of the vector,
// and invalidate the .data() pointer
return result; So the main hazard in this PR would be to guarantee that data is never changed after a |
@Levi-Lesches How's it going? did you start working on this, if not I will submit a PR to work together. |
Nope, our winter break started today :) Happy to start sometime soon but if you have the time go ahead |
Awesome, thanks! |
😄, it works but still needs testing and optimizatios for production usage. Fix it or let me know if you find any bugs. |
imencode()
that does not copy opencv_dart#304The text was updated successfully, but these errors were encountered: