Preferred coding style for error handling?
img-list at ntlworld.com
Wed Aug 27 13:27:04 CDT 2003
On Wednesday 27 Aug 2003 08:09, Jakob Eriksson wrote:
> I have done a lot of C and oldstyle C++ coding, and I have never felt
> the need for a goto. I find that I can almost always do it by having
> many returns instead.
This is the technique I usually use. The only thing you have to watch is to
make sure that you tidy up properly just before each return. In extreme
cases, it's probably better to use goto (especially if undoing a non-existant
action is benign - unfortunately with malloc/free it's not):
if (!(ptr = malloc(...)))
More information about the wine-devel