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
@ -389,8 +389,7 @@ void parse_pathspec(struct pathspec *pathspec,
|
||||
if (!(flags & PATHSPEC_PREFER_CWD))
|
||||
die("BUG: PATHSPEC_PREFER_CWD requires arguments");
|
||||
|
||||
pathspec->items = item = xmalloc(sizeof(*item));
|
||||
memset(item, 0, sizeof(*item));
|
||||
pathspec->items = item = xcalloc(1, sizeof(*item));
|
||||
item->match = prefix;
|
||||
item->original = prefix;
|
||||
item->nowildcard_len = item->len = strlen(prefix);
|
||||
|
Reference in New Issue
Block a user