Clean-up actions directly after/before calling Mat_Critical/Mat_Error
Brought to you by:
chulbe2lsu,
t-beu
The adapted matio for the Modelica environment (see https://trac.modelica.org/Modelica/browser/Modelica/trunk/Modelica/Resources/C-Sources/ModelicaMatIO.c) calls ModelicaFormatError in Mat_Critical (and Mat_Error). By design ModelicaFormatError never returns to the calling function (using setjmp/longjmp exception handling). This is bad for matio where some clean-up (closing file handles, freeing variables etc) is done immediately after Mat_Critical/Mat_Error. For that reason I propose to do the necessary clean-up directly before calling Mat_Critical/Mat_Error.
I'm ok with doing this so long as information from cleaned up variables isn't used in the error message. This seems like it will be tedious to go through and make these changes. Make take a little while.
Only a view number of changes were relevant. See proposed patch.
Chris, did you have some spare minutes to check the proposed patch?