* 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 <egg...@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. 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