fixed memory leaks in modules/features2d/test/test_nearestneighbors.cpp
This commit is contained in:
parent
d81a0df489
commit
f7d36bbad5
@ -161,7 +161,7 @@ void NearestNeighborTest::run( int /*start_from*/ ) {
|
||||
class CV_FlannTest : public NearestNeighborTest
|
||||
{
|
||||
public:
|
||||
CV_FlannTest() {}
|
||||
CV_FlannTest() : NearestNeighborTest(), index(NULL) { }
|
||||
protected:
|
||||
void createIndex( const Mat& data, const IndexParams& params );
|
||||
int knnSearch( Mat& points, Mat& neighbors );
|
||||
@ -172,6 +172,9 @@ protected:
|
||||
|
||||
void CV_FlannTest::createIndex( const Mat& data, const IndexParams& params )
|
||||
{
|
||||
// release previously allocated index
|
||||
releaseModel();
|
||||
|
||||
index = new Index( data, params );
|
||||
}
|
||||
|
||||
@ -238,7 +241,11 @@ int CV_FlannTest::radiusSearch( Mat& points, Mat& neighbors )
|
||||
|
||||
void CV_FlannTest::releaseModel()
|
||||
{
|
||||
delete index;
|
||||
if (index)
|
||||
{
|
||||
delete index;
|
||||
index = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user