Re:Emulating exceptions in C: a case study
by rwmj on Thursday August 27, 2015 @01:00PM
(#10130605)
While I'm not saying this is a good idea, you can combine a pool allocator with longjmp exceptions to get an approximation of unwinding. It requires that you are very careful about structuring your code, but I once wrote a whole web server this way: http://git.annexia.org/?p=rws.git;a=tree (using: http://git.annexia.org/?p=c2lib.git;a=tree ).
[ Parent
| on HN ]
Re:Emulating exceptions in C: a case study
by halayli on Thursday August 27, 2015 @02:08PM
(#10131023)
But sometimes it's not just memory. It can be files you need to close, or any other resource held.
Re:Emulating exceptions in C: a case study
by chaz72 on Thursday August 27, 2015 @04:40PM
(#10131948)
That too can be queued up, with a list of functions to call to free those resources.