From 56d8bdcbfd867d1ac8fb0e14083c8267d6c37727 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 17 Dec 2019 13:09:30 -0800 Subject: [PATCH] fts: tune via calloc * 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 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; -- 2.39.5