Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PointCloud
Flann
提交
27614a68
F
Flann
项目概览
PointCloud
/
Flann
通知
4
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
Flann
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
27614a68
编写于
7月 04, 2012
作者:
M
Marius Muja
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #49 from choni/master
A few memory leaks in hierarchical_clustering_index.h
上级
29dc8c4b
9d7c266e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
27 addition
and
5 deletion
+27
-5
src/cpp/flann/algorithms/hierarchical_clustering_index.h
src/cpp/flann/algorithms/hierarchical_clustering_index.h
+27
-5
未找到文件。
src/cpp/flann/algorithms/hierarchical_clustering_index.h
浏览文件 @
27614a68
...
...
@@ -162,7 +162,7 @@ private:
int
best_index
=
-
1
;
DistanceType
best_val
=
0
;
for
(
int
j
=
0
;
j
<
n
;
++
j
)
{
DistanceType
dist
=
distance
(
dataset
[
centers
[
0
]],
dataset
[
indices
[
j
]],
dataset
.
cols
);
DistanceType
dist
=
distance
(
dataset
[
centers
[
0
]],
dataset
[
indices
[
j
]],
dataset
.
cols
);
for
(
int
i
=
1
;
i
<
index
;
++
i
)
{
DistanceType
tmp_dist
=
distance
(
dataset
[
centers
[
i
]],
dataset
[
indices
[
j
]],
dataset
.
cols
);
if
(
tmp_dist
<
dist
)
{
...
...
@@ -257,6 +257,25 @@ private:
delete
[]
closestDistSq
;
}
/**
* Release the memory which were allocated by new operator.
*/
void
clearMemories
()
{
if
(
root
!=
NULL
)
{
delete
[]
root
;
}
if
(
indices
!=
NULL
)
{
for
(
int
i
=
0
;
i
<
trees_
;
++
i
)
{
if
(
indices
[
i
]
!=
NULL
)
{
delete
[]
indices
[
i
];
}
}
delete
[]
indices
;
}
}
public:
...
...
@@ -298,6 +317,7 @@ public:
trees_
=
get_param
(
params
,
"trees"
,
4
);
root
=
new
NodePtr
[
trees_
];
indices
=
new
int
*
[
trees_
];
for
(
int
i
=
0
;
i
<
trees_
;
++
i
)
indices
[
i
]
=
NULL
;
}
HierarchicalClusteringIndex
(
const
HierarchicalClusteringIndex
&
);
...
...
@@ -310,9 +330,7 @@ public:
*/
virtual
~
HierarchicalClusteringIndex
()
{
if
(
indices
!=
NULL
)
{
delete
[]
indices
;
}
clearMemories
();
}
/**
...
...
@@ -350,6 +368,9 @@ public:
throw
FLANNException
(
"Branching factor must be at least 2"
);
}
for
(
int
i
=
0
;
i
<
trees_
;
++
i
)
{
if
(
indices
[
i
]
!=
NULL
)
{
delete
[]
indices
[
i
];
}
indices
[
i
]
=
new
int
[
size_
];
for
(
size_t
j
=
0
;
j
<
size_
;
++
j
)
{
indices
[
i
][
j
]
=
j
;
...
...
@@ -388,6 +409,7 @@ public:
load_value
(
stream
,
centers_init_
);
load_value
(
stream
,
leaf_size_
);
load_value
(
stream
,
memoryCounter
);
clearMemories
();
indices
=
new
int
*
[
trees_
];
root
=
new
NodePtr
[
trees_
];
for
(
int
i
=
0
;
i
<
trees_
;
++
i
)
{
...
...
@@ -572,7 +594,7 @@ private:
}
//
assign points to clusters
//
assign points to clusters
DistanceType
cost
;
computeLabels
(
indices
,
indices_length
,
&
centers
[
0
],
centers_length
,
&
labels
[
0
],
cost
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录