Skip to content

Commit

Permalink
fix memory leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
pefoley2 committed Nov 24, 2016
1 parent 8849ea3 commit 3f6c943
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 7 additions & 2 deletions symtabAPI/src/Collections.C
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,14 @@ typeCollection::typeCollection() :
*/
typeCollection::~typeCollection()
{
// We sometimes directly delete (refcount == 1) or go through the
// decRefCount (which will delete when refcount == 0)
// delete all of the types
for(const auto& t: typesByName) {
t.second->decrRefCount();
}

for(const auto& t: typesByID) {
t.second->decrRefCount();
}
}

/*
Expand Down
6 changes: 5 additions & 1 deletion symtabAPI/src/Type.C
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,12 @@ void Type::incrRefCount()

void Type::decrRefCount()
{
if (refCount > 0)
if (refCount > 1) {
refCount--;
} else {
delete this;
}

}

std::string &Type::getName()
Expand Down

0 comments on commit 3f6c943

Please sign in to comment.