News for hackers. Stuff that matters.
Re:Exceptions in C with Longjmp and Setjmp by adgar on Sunday March 25, 2012 @08:16AM (#3752384)
> This third one makes using longjmp for exceptions almost untenable in real life code.

No, it's pretty simple. Postgres does it with something called regions: your code essentially becomes transaction-based, where resources that need cleanup are put into a region associated with a try block, and all remaining resources at the end of the block's (successful or failed) execution are freed. It requires slightly more work than in C++, obviously, because you're not using C++.

Re:Exceptions in C with Longjmp and Setjmp by rwmj on Sunday March 25, 2012 @02:51PM (#3753415)
This is nice. It's pretty much how the pool allocator "integration" works. I say integration in quotes because with the pool allocator you (also) have to be careful at the try site that any pools or subpools used in the code that could throw will be freed.