Use MOVE_ARRAY
Use the helper macro MOVE_ARRAY to move arrays. This is shorter and safer, as it automatically infers the size of elements. Patch generated by Coccinelle and contrib/coccinelle/array.cocci in Travis CI's static analysis build job. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
8279ed033f
commit
f919ffebed
6
commit.c
6
commit.c
@ -126,10 +126,8 @@ int register_commit_graft(struct commit_graft *graft, int ignore_dups)
|
||||
ALLOC_GROW(commit_graft, commit_graft_nr + 1, commit_graft_alloc);
|
||||
commit_graft_nr++;
|
||||
if (pos < commit_graft_nr)
|
||||
memmove(commit_graft + pos + 1,
|
||||
commit_graft + pos,
|
||||
(commit_graft_nr - pos - 1) *
|
||||
sizeof(*commit_graft));
|
||||
MOVE_ARRAY(commit_graft + pos + 1, commit_graft + pos,
|
||||
commit_graft_nr - pos - 1);
|
||||
commit_graft[pos] = graft;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user