use COPY_ARRAY for copying arrays

Convert calls of memcpy(3) to use COPY_ARRAY, which shortens and simplifies the code a bit. Patch generated by Coccinelle and contrib/coccinelle/array.cocci. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Jun 15, 2019 at 20:36 UTC 921d49be86bd44ca290c8db6cc6f419dac3ed442
4 files changed +7 -7
fast-import.c
+1 -1
@@ -644,7 +644,7 @@ static struct tree_content *grow_tree_content(
644 struct tree_content *r = new_tree_content(t->entry_count + amt);
645 r->entry_count = t->entry_count;
646 r->delta_depth = t->delta_depth;
647 - memcpy(r->entries,t->entries,t->entry_count*sizeof(t->entries[0]));
647 + COPY_ARRAY(r->entries, t->entries, t->entry_count);
648 release_tree_content(t);
649 return r;
650 }
kwset.c
+1 -1
@@ -475,7 +475,7 @@ kwsprep (kwset_t kws)
475 for (i = 0; i < NCHAR; ++i)
476 kwset->next[i] = next[U(trans[i])];
477 else
478 - memcpy(kwset->next, next, NCHAR * sizeof(struct trie *));
478 + COPY_ARRAY(kwset->next, next, NCHAR);
479 }
480
481 /* Fix things up for any translation table. */
packfile.c
+3 -3
@@ -1269,7 +1269,7 @@ static enum object_type packed_to_object_type(struct repository *r,
1269 if (poi_stack_nr >= poi_stack_alloc && poi_stack == small_poi_stack) {
1270 poi_stack_alloc = alloc_nr(poi_stack_nr);
1271 ALLOC_ARRAY(poi_stack, poi_stack_alloc);
1272 - memcpy(poi_stack, small_poi_stack, sizeof(off_t)*poi_stack_nr);
1272 + COPY_ARRAY(poi_stack, small_poi_stack, poi_stack_nr);
1273 } else {
1274 ALLOC_GROW(poi_stack, poi_stack_nr+1, poi_stack_alloc);
1275 }
@@ -1679,8 +1679,8 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
1679 && delta_stack == small_delta_stack) {
1680 delta_stack_alloc = alloc_nr(delta_stack_nr);
1681 ALLOC_ARRAY(delta_stack, delta_stack_alloc);
1682 - memcpy(delta_stack, small_delta_stack,
1683 - sizeof(*delta_stack)*delta_stack_nr);
1682 + COPY_ARRAY(delta_stack, small_delta_stack,
1683 + delta_stack_nr);
1684 } else {
1685 ALLOC_GROW(delta_stack, delta_stack_nr+1, delta_stack_alloc);
1686 }
pretty.c
+2 -2
@@ -106,8 +106,8 @@ static void setup_commit_formats(void)
106 commit_formats_len = ARRAY_SIZE(builtin_formats);
107 builtin_formats_len = commit_formats_len;
108 ALLOC_GROW(commit_formats, commit_formats_len, commit_formats_alloc);
109 - memcpy(commit_formats, builtin_formats,
110 - sizeof(*builtin_formats)*ARRAY_SIZE(builtin_formats));
109 + COPY_ARRAY(commit_formats, builtin_formats,
110 + ARRAY_SIZE(builtin_formats));
111
112 git_config(git_pretty_formats_config, NULL);
113 }