in reply to Re: Breakin' the rules, Breakin' the rules
in thread Breakin' the rules, Breakin' the rules
I'ved used goto in C to handle cleanup of dynamically allocated resources.
BOOL some_func() { BOOL success = FALSE; allocate_temp_resources(); if (might_fail()) { goto Cleanup; } if (might_fail()) { goto Cleanup; } success = TRUE; Cleanup: free_temp_resources(); return success; }
Suiteable alternatives can be written in C++ and Perl thanks to destructors.
|
|---|