Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Development
OpenFOAM-plus
Commits
f4a5d276
Commit
f4a5d276
authored
May 01, 2019
by
Mark Olesen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BUG: avoid memory leak caused by IOobjectList::filterObjects (
#1286
)
parent
ea1edf76
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
7 deletions
+34
-7
src/OpenFOAM/db/IOobjectList/IOobjectListTemplates.C
src/OpenFOAM/db/IOobjectList/IOobjectListTemplates.C
+34
-7
No files found.
src/OpenFOAM/db/IOobjectList/IOobjectListTemplates.C
View file @
f4a5d276
...
...
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2018
-2019
OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
...
...
@@ -622,11 +622,16 @@ Foam::label Foam::IOobjectList::filterClasses
const
bool
pruning
)
{
// return HashPtrTable<IOobject>::filterValues
// (
// [&](const IOobject* io){ return pred(io->headerClassName()); },
// pruning
// );
// This is like
// return HashPtrTable<IOobject>::filterValues
// (
// [&](const IOobject* io){ return pred(io->headerClassName()); },
// pruning
// );
// which is really
// return HashTable<IOobject*>::filterValues
//
// except that it does not leak
label
changed
=
0
;
...
...
@@ -654,7 +659,29 @@ Foam::label Foam::IOobjectList::filterObjects
const
bool
pruning
)
{
return
HashPtrTable
<
IOobject
>::
filterKeys
(
pred
,
pruning
);
// This is like
// return HashPtrTable<IOobject>::filterKeys(pred, pruning);
// which is really
// return HashTable<IOobject*>::filterKeys(pred, pruning);
//
// except that it does not leak
label
changed
=
0
;
for
(
iterator
iter
=
begin
();
iter
!=
end
();
++
iter
)
{
// Matches? either prune (pruning) or keep (!pruning)
if
(
(
pred
(
iter
.
key
())
?
pruning
:
!
pruning
)
&&
erase
(
iter
)
)
{
++
changed
;
}
}
return
changed
;
}
...
...
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