Deutsch   English   Français   Italiano  
<v5acc8$imk3$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Lawrence D'Oliveiro <ldo@nz.invalid>
Newsgroups: comp.lang.c
Subject: Re: Fixing a sample from K&R book using cake static analyser
Date: Sun, 23 Jun 2024 23:50:33 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 30
Message-ID: <v5acc8$imk3$1@dont-email.me>
References: <v53sl1$35qt7$1@dont-email.me> <v558hv$3dskb$1@dont-email.me>
	<20240623022343.ec355c69a3d9eb03ad4a50f2@gmail.moc>
	<v57mqf$3vq0p$5@dont-email.me> <v57o51$3vj82$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 24 Jun 2024 01:50:33 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="3048fea01d51f9337586ac8e02824e6c";
	logging-data="612995"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1930gy2cRORr9jQ/S6t3s3a"
User-Agent: Pan/0.158 (Avdiivka; )
Cancel-Lock: sha1:eHg7yKxw1d3J71AUNPOVR2afTas=
Bytes: 1934

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.