From 932a646df6f128c66c9be6983aaa5745c6e7d5e9 Mon Sep 17 00:00:00 2001 From: Lars Ivar Hatledal Date: Thu, 3 Oct 2024 09:33:52 +0200 Subject: [PATCH] call free_instance on destruction --- 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(); } };