Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call free_instance on destruction (regardless of terminate status) #148

Merged
merged 2 commits into from
Oct 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions include/fmi4cpp/fmu_instance_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,13 @@ class fmu_instance_base : public virtual fmu_instance<model_description>
return library_->reset(c_);
}

bool terminate() override
{
return terminate(true);
}

bool terminate(bool freeInstance)
bool terminate()
{
if (!this->terminated_) {
this->terminated_ = true;
if (!library_->terminate(c_)) {
return false;
}
this->free_instance();
}
return true;
}
Expand Down Expand Up @@ -257,6 +251,7 @@ class fmu_instance_base : public virtual fmu_instance<model_description>
~fmu_instance_base()
{
terminate();
free_instance();
}
};

Expand Down
Loading