Merge pull request #18016 from pemmanuelviel:pev--cleaner-hierarchical-clustering

pull/18037/head
Alexander Alekhin 4 years ago
commit 2c32cb743c
  1. 39
      modules/flann/include/opencv2/flann/hierarchical_clustering_index.h

@ -404,34 +404,16 @@ public:
*/
virtual ~HierarchicalClusteringIndex()
{
free_elements();
if (root!=NULL) {
delete[] root;
}
if (indices!=NULL) {
free_indices();
delete[] indices;
}
}
/**
* Release the inner elements of indices[]
*/
void free_elements()
{
if (indices!=NULL) {
for(int i=0; i<trees_; ++i) {
if (indices[i]!=NULL) {
delete[] indices[i];
indices[i] = NULL;
}
}
}
}
/**
* Returns size of index.
*/
@ -467,7 +449,7 @@ public:
throw FLANNException("Branching factor must be at least 2");
}
free_elements();
free_indices();
for (int i=0; i<trees_; ++i) {
indices[i] = new int[size_];
@ -503,13 +485,12 @@ public:
void loadIndex(FILE* stream) CV_OVERRIDE
{
free_elements();
if (root!=NULL) {
delete[] root;
}
if (indices!=NULL) {
free_indices();
delete[] indices;
}
@ -649,6 +630,20 @@ private:
}
/**
* Release the inner elements of indices[]
*/
void free_indices()
{
if (indices!=NULL) {
for(int i=0; i<trees_; ++i) {
if (indices[i]!=NULL) {
delete[] indices[i];
indices[i] = NULL;
}
}
}
}
void computeLabels(int* dsindices, int indices_length, int* centers, int centers_length, int* labels, DistanceType& cost)

Loading…
Cancel
Save