Sujet : Re: Fixing a sample from K&R book using cake static analyser
De : ldo (at) *nospam* nz.invalid (Lawrence D'Oliveiro)
Groupes : comp.lang.cDate : 24. Jun 2024, 00:50:33
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v5acc8$imk3$1@dont-email.me>
References : 1 2 3 4 5
User-Agent : Pan/0.158 (Avdiivka; )
On Sun, 23 Jun 2024 00:53:04 +0100, bart wrote:
On 23/06/2024 00:30, Lawrence D'Oliveiro wrote:
>
On Sun, 23 Jun 2024 02:23:43 +0300, Anton Shepelev wrote:
Why are you so afraid of `goto' ...
Look up the concept of a “Nassi-Shneiderman diagram”. It allows
arbitrary nesting of complex code, with dynamic allocation going on,
while minimizing flow-control headaches.
Another point is idempotency of disposal routines. By which I mean that
attempting to free a NULL pointer is a harmless no-op. How many times have
you seen pointless rigmarole like
if (p1)
free(p1);
if (p2)
free(p2);
if (p3)
free(p3);
when it could be written so much more simply as
free(p1);
free(p2);
free(p3);
You’ll notice that my np_free routine can be used in the same way.