2 ms·
If the compiler in question does tail call optimization (or even if not), maybe one could write a cleanup function that takes the place of the goto block, but t
by nitrogen 11y ago
If the compiler in question does tail call optimization (or even if not), maybe one could write a cleanup function that takes the place of the goto block, but this looks pretty ugly with all the parameters:
int cleanup(void *ptr1, char *ptr2, struct foo *ptr3, int *ptr4, union xyz *ptr5, int ret)
{
free(ptr1);
// etc.
return ret;
}
// later...
if(fail1) {
return cleanup(a, b, c, d, e, -1);
}