From 71d30042e4044bdd12ccf9fa756046b801e46502 Mon Sep 17 00:00:00 2001 From: Lars Ivar Hatledal Date: Thu, 3 Oct 2024 12:31:30 +0200 Subject: [PATCH] call free_instance on destruction (#148) --- include/fmi4cpp/fmu_instance_base.hpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/include/fmi4cpp/fmu_instance_base.hpp b/include/fmi4cpp/fmu_instance_base.hpp index e1e2969..9ea411b 100644 --- a/include/fmi4cpp/fmu_instance_base.hpp +++ b/include/fmi4cpp/fmu_instance_base.hpp @@ -70,19 +70,13 @@ class fmu_instance_base : public virtual fmu_instance 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; } @@ -257,6 +251,7 @@ class fmu_instance_base : public virtual fmu_instance ~fmu_instance_base() { terminate(); + free_instance(); } };