Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH] remove unnecessary checks for NULL in zfree and zsfree



I quoted the C11 standard because it's the one I'm most familiar with, but that particular clause has been present since the first ANSI draft. In the C89 standard it's section 4.10.3.2: ``If ptr is a null pointer, no action occurs.'' Even if zsh were to rely on some variant of GNU C, no extension that I know of modifies this part of the standard. Unless you know of a particular platform with a particularly bad compiler that you want to support, I recommend taking advantage of these kinds of guarantees.
________________________________
From: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
Sent: Thursday, March 1, 2018 1:15 AM
To: zsh-workers@xxxxxxx
Subject: Re: [PATCH] remove unnecessary checks for NULL in zfree and zsfree

On Thu, 1 Mar 2018 01:17:12 +0000
Taylor West <krokodileglue@xxxxxxxxxxx> wrote:
> According to section 7.22.3.3 paragraph 2 of the final committee draft
> of the C11 standard, if free() is passed a NULL pointer then "no
> action occurs". The current checks on `p' in zfree and zsfree are
> unnecessary---this patch removes them.

We haven't even progressed to C99 yet... zsh is designed to be defensive
about some pretty old stuff.  Unfortunately, it's quite difficult to
know when where it's still being compiled.

pws


Messages sorted by: Reverse Date, Date, Thread, Author