Browse Source

moving to weak_pointers in variables to resolve memory leak in expression manager

tempestpy_adaptions
dehnert 7 years ago
parent
commit
533585fda6
  1. 5
      src/storm/storage/expressions/Variable.cpp
  2. 2
      src/storm/storage/expressions/Variable.h

5
src/storm/storage/expressions/Variable.cpp

@ -16,7 +16,7 @@ namespace storm {
}
bool Variable::operator==(Variable const& other) const {
return manager == other.manager && index == other.index;
return &this->getManager() == &other.getManager() && index == other.index;
}
bool Variable::operator!=(Variable const& other) const {
@ -48,8 +48,7 @@ namespace storm {
}
ExpressionManager const& Variable::getManager() const {
STORM_LOG_ASSERT(manager != nullptr, "Manager is null.");
return *manager;
return *manager.lock();
}
bool Variable::hasBooleanType() const {

2
src/storm/storage/expressions/Variable.h

@ -138,7 +138,7 @@ namespace storm {
private:
// The manager that is responsible for this variable.
std::shared_ptr<ExpressionManager const> manager;
std::weak_ptr<ExpressionManager const> manager;
// The index of the variable.
uint_fast64_t index;

Loading…
Cancel
Save