[Olsr-dev] Good use patterns of "goto" - or not? (was Re: httpinfo IPv6 patch)
Henning Rogge
(spam-protected)
Tue Nov 18 12:58:20 CET 2008
Am Tuesday 18 November 2008 12:36:54 schrieb Bernd Petrovitsch:
If we have to use goto, I would use it this way... ;)
> ---- snip ----
> int x(...)
> {
> int rv = -1;
> x = NULL;
> y = NULL;
> z = NULL;
> [...]
> x = malloc(a);
> [...]
> if(some_error) {
> goto free_and_out;
> }
> [...]
> y = malloc(b);
> [...]
> if(some_error) {
> goto free_and_out;
> }
> [...]
> z = malloc(c);
> [...]
> if(some_error) {
> goto free_and_out;
> }
> [...]
> rv = 0;
> free_and_out:
> free(z);
> free(y);
> free(x);
> return rv;
> }
> ---- snip ----
But I still don't like it... ^^
Henning
*************************************************
Diplom Informatiker Henning Rogge
Forschungsgesellschaft für
Angewandte Naturwissenschaften e. V. (FGAN)
Neuenahrer Str. 20, 53343 Wachtberg, Germany
Tel.: 0049 (0)228 9435-961
Fax: 0049 (0)228 9435-685
E-Mail: (spam-protected)
Web: www.fgan.de
************************************************
Sitz der Gesellschaft: Bonn
Registergericht: Amtsgericht Bonn VR 2530
Vorstand: Dr. rer. nat. Ralf Dornhaus (Vors.), Prof. Dr. Joachim Ender
(Stellv.)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.olsr.org/pipermail/olsr-dev/attachments/20081118/6627f81a/attachment.sig>
More information about the Olsr-dev
mailing list