]> Savannah Git Hosting - gnulib.git/commitdiff
fts: tune via calloc
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 17 Dec 2019 21:09:30 +0000 (13:09 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 18 Dec 2019 05:47:07 +0000 (21:47 -0800)
* lib/fts.c (fts_open): Prefer calloc to malloc + memset.

ChangeLog
lib/fts.c

index ce3f8b2b7857068053bbe8254ec2f39a08b7b001..f22770294bd3135a0ce85ab1e4269981cdb8f97c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2019-12-17  Paul Eggert  <eggert@cs.ucla.edu>
 
+       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.
 
index 8b7a4de9c157fb4f154a6630344e831a790df6a8..d99a33cf3d4f90320f420f1683bdc5c10edafcec 100644 (file)
--- 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;