bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/4] fts: tune via calloc


From: Paul Eggert
Subject: [PATCH 2/4] fts: tune via calloc
Date: Tue, 17 Dec 2019 21:47:22 -0800

* lib/fts.c (fts_open): Prefer calloc to malloc + memset.
---
 ChangeLog | 3 +++
 lib/fts.c | 4 ++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ce3f8b2b7..f22770294 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2019-12-17  Paul Eggert  <address@hidden>
 
+       fts: tune via calloc
+       * lib/fts.c (fts_open): Prefer calloc to malloc + memset.
+
        dfa: tune via xzalloc
        * lib/dfa.c (dfaoptimize): Prefer xzalloc to xmalloc + memset.
 
diff --git a/lib/fts.c b/lib/fts.c
index 8b7a4de9c..d99a33cf3 100644
--- a/lib/fts.c
+++ b/lib/fts.c
@@ -381,9 +381,9 @@ fts_open (char * const *argv,
         }
 
         /* Allocate/initialize the stream */
-        if ((sp = malloc(sizeof(FTS))) == NULL)
+        sp = calloc (1, sizeof *sp);
+        if (sp == NULL)
                 return (NULL);
-        memset(sp, 0, sizeof(FTS));
         sp->fts_compar = compar;
         sp->fts_options = options;
 
-- 
2.17.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]