use CALLOC_ARRAY
Add and apply a semantic patch for converting code that open-codes CALLOC_ARRAY to use it instead. It shortens the code and infers the element size automatically. Signed-off-by: René 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
f1121499e6
commit
ca56dadb4b
6
dir.c
6
dir.c
@ -1488,7 +1488,7 @@ static void prep_exclude(struct dir_struct *dir,
|
||||
const char *cp;
|
||||
struct oid_stat oid_stat;
|
||||
|
||||
stk = xcalloc(1, sizeof(*stk));
|
||||
CALLOC_ARRAY(stk, 1);
|
||||
if (current < 0) {
|
||||
cp = base;
|
||||
current = 0;
|
||||
@ -3162,7 +3162,7 @@ void write_untracked_extension(struct strbuf *out, struct untracked_cache *untra
|
||||
int varint_len;
|
||||
const unsigned hashsz = the_hash_algo->rawsz;
|
||||
|
||||
ouc = xcalloc(1, sizeof(*ouc));
|
||||
CALLOC_ARRAY(ouc, 1);
|
||||
stat_data_to_disk(&ouc->info_exclude_stat, &untracked->ss_info_exclude.stat);
|
||||
stat_data_to_disk(&ouc->excludes_file_stat, &untracked->ss_excludes_file.stat);
|
||||
ouc->dir_flags = htonl(untracked->dir_flags);
|
||||
@ -3373,7 +3373,7 @@ struct untracked_cache *read_untracked_extension(const void *data, unsigned long
|
||||
if (next + exclude_per_dir_offset + 1 > end)
|
||||
return NULL;
|
||||
|
||||
uc = xcalloc(1, sizeof(*uc));
|
||||
CALLOC_ARRAY(uc, 1);
|
||||
strbuf_init(&uc->ident, ident_len);
|
||||
strbuf_add(&uc->ident, ident, ident_len);
|
||||
load_oid_stat(&uc->ss_info_exclude,
|
||||
|
||||
Reference in New Issue
Block a user