This is going to be wrapped in CFFI but I could use help on the C side a bit...I have a whole list of C wrappers for OpenCV C++ functions like the one below. And all of them return a "new". I can't change them because they are becoming part of OpenCV and it would make my library perfect to have a consistently updated skeleton to wrap around.
Code: Select all
Mat* cv_create_Mat() {
return new Mat();
}
I can't rewrite the C wrapper for the C++ function so I wrote a delete wrapper like the below,The memory I'm trying to free is a Mat*, Mat is an OpenCV c++ class...and the delete wrapper works There is absolutely no memory leakage at all, but I have a lot of other C wrappers for OpenCV C++ functions that return a new pointer...there is at least 10 of 15 and my intention is to not have to write a separate delete wrapper for all of them. If you can show me how to write one delete wrapper that would free any pointer I give to it that would be great...I have CvSVMParams*, Brisk*, RotatedRect*, CVANN_MLP* pointers there are a few others as well...Any help at this is greatly valued.
Code: Select all
void delete_ptr(void* ptr) {
delete (Mat*)ptr;
}