From: Paul Eggert Date: Tue, 17 Dec 2019 21:09:30 +0000 (-0800) Subject: fts: tune via calloc X-Git-Tag: v1.0~4487 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=56d8bdcbfd867d1ac8fb0e14083c8267d6c37727;p=gnulib.git fts: tune via calloc * lib/fts.c (fts_open): Prefer calloc to malloc + memset. --- diff --git a/ChangeLog b/ChangeLog index ce3f8b2b78..f22770294b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2019-12-17 Paul Eggert + 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 8b7a4de9c1..d99a33cf3d 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;