>ONERROR handle; >SET_ONERROR (handle, my_free_function, my_mem); >/* do stuff which may throw */ >UNSET_ONERROR (handle); > >If you want my_free_function to be called even if nothing was thrown, >use CALL_AND_UNSET_ONERROR instead.
That's probably the proper solution in this case, but it's not quite a
catch...
JMP_BUF ctx;
if (SETJMP(ctx)) {
/* Something was thrown. */
} else {
/* Some code that might throw. */
}
UNSETJMP(ctx);
