From: Phil R. <p.d...@gm...> - 2016-02-28 16:42:07
|
Do we do any other resource allocation other than memory? I guess we deal with files too, so that answer makes a good point that they need considering too. It's not quite just a goto. The registers are all reset too, so the stack pointer function pointer etc are all put back, but you are correct that the stack is left as it was so any allocated resources get left. They therefore need managing in a way that they can be freed when the plplot returns. What I really don't want to do here is obfuscate the code to the point where others are not happy to tinker with things. I'm starting to feel that there is a real risk of that. What I will do is set up a single API function to use setjmp and longjmp and I will send that around as a patch. If and only if there is consensus that people are happy with how this works then I will continue. Phil On 28 February 2016 at 03:47, Hazen Babcock <hba...@ma...> wrote: > > > On 02/27/2016 10:10 PM, Alan W. Irwin wrote: >> >> On 2016-02-27 23:22-0000 Phil Rosenberg wrote: >> >>> Perhaps it would be good for Hazen and Alan to start looking >> >> in more detail at implementing the error code propagation? If there >> are tools to help with that, then maybe it will be easier than I >> suspect. >> >> I am now confident of the return code method because of the >> 'warn_unused_result' gcc attribute capability, but let's not even >> start the substantial work required for this alternative unless it is >> made necessary because you run into some showstopper issue with the C >> exception-based alternative. > > > Before you begin I would encourage you to read this: > > http://stackoverflow.com/questions/14685406/practical-usage-of-setjmp-and-longjmp-in-c > > Particularly the 2nd and 3rd answers. As they point out, this is *not* C++ > exception handling in C, this is just a goto statement. To me that would be > a showstopper issue. However, who does the work decides, so if this approach > is still your preference then I won't persist in trying to dissuade you. > > -Hazen |