Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
92fc7639
Commit
92fc7639
authored
Dec 18, 2013
by
Pierre-Emmanuel Viel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix some memory leaks in HierarchicalClusteringIndex
parent
459e7d4a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
0 deletions
+42
-0
hierarchical_clustering_index.h
...ann/include/opencv2/flann/hierarchical_clustering_index.h
+42
-0
No files found.
modules/flann/include/opencv2/flann/hierarchical_clustering_index.h
View file @
92fc7639
...
@@ -298,6 +298,11 @@ public:
...
@@ -298,6 +298,11 @@ public:
trees_
=
get_param
(
params
,
"trees"
,
4
);
trees_
=
get_param
(
params
,
"trees"
,
4
);
root
=
new
NodePtr
[
trees_
];
root
=
new
NodePtr
[
trees_
];
indices
=
new
int
*
[
trees_
];
indices
=
new
int
*
[
trees_
];
for
(
int
i
=
0
;
i
<
trees_
;
++
i
)
{
root
[
i
]
=
NULL
;
indices
[
i
]
=
NULL
;
}
}
}
HierarchicalClusteringIndex
(
const
HierarchicalClusteringIndex
&
);
HierarchicalClusteringIndex
(
const
HierarchicalClusteringIndex
&
);
...
@@ -310,11 +315,34 @@ public:
...
@@ -310,11 +315,34 @@ public:
*/
*/
virtual
~
HierarchicalClusteringIndex
()
virtual
~
HierarchicalClusteringIndex
()
{
{
free_elements
();
if
(
root
!=
NULL
)
{
delete
[]
root
;
}
if
(
indices
!=
NULL
)
{
if
(
indices
!=
NULL
)
{
delete
[]
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.
* Returns size of index.
*/
*/
...
@@ -349,6 +377,9 @@ public:
...
@@ -349,6 +377,9 @@ public:
if
(
branching_
<
2
)
{
if
(
branching_
<
2
)
{
throw
FLANNException
(
"Branching factor must be at least 2"
);
throw
FLANNException
(
"Branching factor must be at least 2"
);
}
}
free_elements
();
for
(
int
i
=
0
;
i
<
trees_
;
++
i
)
{
for
(
int
i
=
0
;
i
<
trees_
;
++
i
)
{
indices
[
i
]
=
new
int
[
size_
];
indices
[
i
]
=
new
int
[
size_
];
for
(
size_t
j
=
0
;
j
<
size_
;
++
j
)
{
for
(
size_t
j
=
0
;
j
<
size_
;
++
j
)
{
...
@@ -388,6 +419,17 @@ public:
...
@@ -388,6 +419,17 @@ public:
load_value
(
stream
,
centers_init_
);
load_value
(
stream
,
centers_init_
);
load_value
(
stream
,
leaf_size_
);
load_value
(
stream
,
leaf_size_
);
load_value
(
stream
,
memoryCounter
);
load_value
(
stream
,
memoryCounter
);
free_elements
();
if
(
root
!=
NULL
)
{
delete
[]
root
;
}
if
(
indices
!=
NULL
)
{
delete
[]
indices
;
}
indices
=
new
int
*
[
trees_
];
indices
=
new
int
*
[
trees_
];
root
=
new
NodePtr
[
trees_
];
root
=
new
NodePtr
[
trees_
];
for
(
int
i
=
0
;
i
<
trees_
;
++
i
)
{
for
(
int
i
=
0
;
i
<
trees_
;
++
i
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment