diff options
| author | Junio C Hamano <gitster@pobox.com> | 2021-03-19 15:25:38 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2021-03-19 15:25:38 -0700 |
| commit | 92ccd7b7529a852583c5033ba28b4414cd2f7654 (patch) | |
| tree | bce1548bcd2cd806a4524b812fb56f19b397b7d2 /builtin/index-pack.c | |
| parent | Merge branch 'rs/avoid-null-statement-after-macro-call' (diff) | |
| parent | cocci: allow xcalloc(1, size) (diff) | |
| download | git-92ccd7b7529a852583c5033ba28b4414cd2f7654.tar.gz git-92ccd7b7529a852583c5033ba28b4414cd2f7654.zip | |
Merge branch 'rs/calloc-array'
CALLOC_ARRAY() macro replaces many uses of xcalloc().
* rs/calloc-array:
cocci: allow xcalloc(1, size)
use CALLOC_ARRAY
git-compat-util.h: drop trailing semicolon from macro definition
Diffstat (limited to 'builtin/index-pack.c')
| -rw-r--r-- | builtin/index-pack.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/builtin/index-pack.c b/builtin/index-pack.c index bad5748807..21899687e2 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -185,7 +185,7 @@ static void init_thread(void) if (show_stat) pthread_mutex_init(&deepest_delta_mutex, NULL); pthread_key_create(&key, NULL); - thread_data = xcalloc(nr_threads, sizeof(*thread_data)); + CALLOC_ARRAY(thread_data, nr_threads); for (i = 0; i < nr_threads; i++) { thread_data[i].pack_fd = open(curr_pack, O_RDONLY); if (thread_data[i].pack_fd == -1) @@ -1674,7 +1674,7 @@ static void show_pack_info(int stat_only) unsigned long *chain_histogram = NULL; if (deepest_delta) - chain_histogram = xcalloc(deepest_delta, sizeof(unsigned long)); + CALLOC_ARRAY(chain_histogram, deepest_delta); for (i = 0; i < nr_objects; i++) { struct object_entry *obj = &objects[i]; @@ -1912,10 +1912,10 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix) curr_pack = open_pack_file(pack_name); parse_pack_header(); - objects = xcalloc(st_add(nr_objects, 1), sizeof(struct object_entry)); + CALLOC_ARRAY(objects, st_add(nr_objects, 1)); if (show_stat) - obj_stat = xcalloc(st_add(nr_objects, 1), sizeof(struct object_stat)); - ofs_deltas = xcalloc(nr_objects, sizeof(struct ofs_delta_entry)); + CALLOC_ARRAY(obj_stat, st_add(nr_objects, 1)); + CALLOC_ARRAY(ofs_deltas, nr_objects); parse_pack_objects(pack_hash); if (report_end_of_input) write_in_full(2, "\0", 1); |
