Skip to content

Commit 921d49b

Browse files
rscharfegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 177fbab commit 921d49b

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

fast-import.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ static struct tree_content *grow_tree_content(
644644
struct tree_content *r = new_tree_content(t->entry_count + amt);
645645
r->entry_count = t->entry_count;
646646
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);
648648
release_tree_content(t);
649649
return r;
650650
}

kwset.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ kwsprep (kwset_t kws)
475475
for (i = 0; i < NCHAR; ++i)
476476
kwset->next[i] = next[U(trans[i])];
477477
else
478-
memcpy(kwset->next, next, NCHAR * sizeof(struct trie *));
478+
COPY_ARRAY(kwset->next, next, NCHAR);
479479
}
480480

481481
/* Fix things up for any translation table. */

packfile.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -1269,7 +1269,7 @@ static enum object_type packed_to_object_type(struct repository *r,
12691269
if (poi_stack_nr >= poi_stack_alloc && poi_stack == small_poi_stack) {
12701270
poi_stack_alloc = alloc_nr(poi_stack_nr);
12711271
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);
12731273
} else {
12741274
ALLOC_GROW(poi_stack, poi_stack_nr+1, poi_stack_alloc);
12751275
}
@@ -1679,8 +1679,8 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
16791679
&& delta_stack == small_delta_stack) {
16801680
delta_stack_alloc = alloc_nr(delta_stack_nr);
16811681
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);
16841684
} else {
16851685
ALLOC_GROW(delta_stack, delta_stack_nr+1, delta_stack_alloc);
16861686
}

pretty.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ static void setup_commit_formats(void)
106106
commit_formats_len = ARRAY_SIZE(builtin_formats);
107107
builtin_formats_len = commit_formats_len;
108108
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));
111111

112112
git_config(git_pretty_formats_config, NULL);
113113
}

0 commit comments

Comments
 (0)