Re: [hackers] [sent] [PATCH 1/3] sent.c: Drop unnecessary NULL checks

From: Antonio Quartulli <>
Date: Mon, 4 Jul 2022 10:27:54 +0200


On 04/07/2022 10:19, NRK wrote:
> Hi Laslo,
> On Sun, Jun 26, 2022 at 11:16:32PM +0200, Laslo Hunhold wrote:
>> come on, it is general knowledge that free() accepts NULL arguments.
> I don't think that's a true. If it were general knowledge then we
> wouldn't see the pattern of `if (ptr) free(ptr)` in the code to begin
> with.
> And overall, I don't believe most "resource-release" functions have this
> behavior. For example fclose, closedir, munmap etc don't accept NULL
> arg. So `free` is more of an exception to the general knowledge.

Just wanted to share my opinion: defining what's "general knowledge" can
prove to be extremely non trivial.

I'd say that if the language spec says so, the manpage says so and it is
known that compilers obey to the spec (as they should), the feature
should be deemed well defined and thus used.

Some people do not keep up with the various changes in a language and
may get stuck on an older version (which for example does not behave
this way). But this is not, IMHO, a good reason to not evolve the code
(especially when it gets simpler)


Antonio Quartulli
Received on Mon Jul 04 2022 - 10:27:54 CEST

This archive was generated by hypermail 2.3.0 : Mon Jul 04 2022 - 11:24:32 CEST