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:
committed by
Junio C Hamano
parent
ebc5da3208
commit
51a60f5bfb
@ -362,8 +362,7 @@ static void set_thread_data(struct thread_local *data)
|
||||
|
||||
static struct base_data *alloc_base_data(void)
|
||||
{
|
||||
struct base_data *base = xmalloc(sizeof(struct base_data));
|
||||
memset(base, 0, sizeof(*base));
|
||||
struct base_data *base = xcalloc(1, sizeof(struct base_data));
|
||||
base->ref_last = -1;
|
||||
base->ofs_last = -1;
|
||||
return base;
|
||||
|
||||
Reference in New Issue
Block a user