diff --git a/lemon/glpk.h b/lemon/glpk.h --- a/lemon/glpk.h +++ b/lemon/glpk.h @@ -100,16 +100,20 @@ virtual void _clear(); + private: + + static void freeEnv(); + + struct FreeEnvHelper { + ~FreeEnvHelper() { + freeEnv(); + } + }; + + static FreeEnvHelper freeEnvHelper; + public: - /// \brief Deallocates the globally allocated memory of GLPK. - - /// Deallocates the globally allocated memory of GLPK. \note - /// Usually, it do not have to be called, because the GLPK use - /// only a small amount of global memory, and it is deallocated - /// automatically at the end of program. - static void freeEnv(); - ///Pointer to the underlying GLPK data structure. LPX *lpx() {return lp;} ///Const pointer to the underlying GLPK data structure.