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

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



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@xxxxxxxxxxx>
Sent: Wednesday, February 28, 2018 5:15 PM
To: zsh-workers@xxxxxxx
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



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