zsh-workers
 help / color / mirror / code / Atom feed
From: Taylor West <krokodileglue@outlook.com>
To: "zsh-workers@zsh.org" <zsh-workers@zsh.org>
Subject: Re: [PATCH] remove unnecessary checks for NULL in zfree and zsfree
Date: Thu, 1 Mar 2018 01:17:12 +0000	[thread overview]
Message-ID: <SN1PR06MB22887FAE0FD9C98D54754312B1C60@SN1PR06MB2288.namprd06.prod.outlook.com> (raw)
In-Reply-To: <SN1PR06MB22882C38BE26E6312E16411FB1C60@SN1PR06MB2288.namprd06.prod.outlook.com>

[-- Attachment #1: Type: text/plain, Size: 977 bytes --]

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.

________________________________
From: Taylor West <KrokodileGlue@outlook.com>
Sent: Wednesday, February 28, 2018 5:15 PM
To: zsh-workers@zsh.org
Cc: Taylor West
Subject: [PATCH] remove unnecessary checks for NULL in zfree and zsfree

---
 Src/mem.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/Src/mem.c b/Src/mem.c
index f120819..77e4375 100644
--- a/Src/mem.c
+++ b/Src/mem.c
@@ -1885,16 +1885,14 @@ bin_mem(char *name, char **argv, Options ops, int func)
 mod_export void
 zfree(void *p, UNUSED(int sz))
 {
-    if (p)
-       free(p);
+    free(p);
 }

 /**/
 mod_export void
 zsfree(char *p)
 {
-    if (p)
-       free(p);
+    free(p);
 }

 /**/
--
2.9.5


  reply	other threads:[~2018-03-01  1:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-01  1:15 Taylor West
2018-03-01  1:17 ` Taylor West [this message]
2018-03-01  9:15   ` Peter Stephenson
2018-03-01 13:29     ` Taylor West
2018-03-01 19:45       ` Peter Stephenson
2018-03-01 21:37         ` Joey Pabalinas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=SN1PR06MB22887FAE0FD9C98D54754312B1C60@SN1PR06MB2288.namprd06.prod.outlook.com \
    --to=krokodileglue@outlook.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).