ENH: avoid memory leaks for HashPtrTable, PtrMap insertion (issue #749)

- disallow insert() of raw pointers, since a failed insertion
  (ie, entry already existed) results in an unmanaged pointer.

  Either insert using an autoPtr, or set() with raw pointers or autoPtr.

- IOobjectList::add() now takes an autoPtr instead of an object reference

- IOobjectList::remove() now returns an autoPtr instead of a raw pointer
This commit is contained in:
Mark Olesen
2018-05-17 09:56:36 +01:00
parent 46b768628c
commit 48d654cf19
30 changed files with 549 additions and 261 deletions

View File

@ -122,11 +122,10 @@ void Foam::functionObjects::runTimePostPro::scene::readColours
const dictionary& dict
)
{
const wordList colours = dict.toc();
forAll(colours, i)
const wordList colours(dict.toc());
for (const word& c : colours)
{
const word& c = colours[i];
colours_.insert(c, Function1<vector>::New(c, dict).ptr());
colours_.insert(c, Function1<vector>::New(c, dict));
}
}