use xcalloc() to allocate zero-initialized memory

Use xcalloc() instead of xmalloc() followed by memset() to allocate
and zero out memory because it's shorter and avoids duplicating the
function parameters.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
René Scharfe
2014-07-19 15:56:26 +02:00
committed by Junio C Hamano
parent ebc5da3208
commit 51a60f5bfb
4 changed files with 4 additions and 8 deletions

View File

@ -621,8 +621,7 @@ static int *list_and_choose(struct menu_opts *opts, struct menu_stuff *stuff)
nr += chosen[i];
}
result = xmalloc(sizeof(int) * (nr + 1));
memset(result, 0, sizeof(int) * (nr + 1));
result = xcalloc(nr + 1, sizeof(int));
for (i = 0; i < stuff->nr && j < nr; i++) {
if (chosen[i])
result[j++] = i;