diff options
author | SZEDER Gábor <szeder.dev@gmail.com> | 2018-01-22 18:50:09 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-01-22 20:32:51 +0100 |
commit | f919ffebed3c570bf3c2a5f36444527ea5df42de (patch) | |
tree | 3d89f307b743c893848413a72d32b36e9fd8ec17 /diffcore-rename.c | |
parent | Git 2.16.1 (diff) | |
download | git-f919ffebed3c570bf3c2a5f36444527ea5df42de.tar.xz git-f919ffebed3c570bf3c2a5f36444527ea5df42de.zip |
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>
Diffstat (limited to 'diffcore-rename.c')
-rw-r--r-- | diffcore-rename.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/diffcore-rename.c b/diffcore-rename.c index 245e999fe5..888a4b0189 100644 --- a/diffcore-rename.c +++ b/diffcore-rename.c @@ -57,8 +57,8 @@ static int add_rename_dst(struct diff_filespec *two) ALLOC_GROW(rename_dst, rename_dst_nr + 1, rename_dst_alloc); rename_dst_nr++; if (first < rename_dst_nr) - memmove(rename_dst + first + 1, rename_dst + first, - (rename_dst_nr - first - 1) * sizeof(*rename_dst)); + MOVE_ARRAY(rename_dst + first + 1, rename_dst + first, + rename_dst_nr - first - 1); rename_dst[first].two = alloc_filespec(two->path); fill_filespec(rename_dst[first].two, &two->oid, two->oid_valid, two->mode); @@ -98,8 +98,8 @@ static struct diff_rename_src *register_rename_src(struct diff_filepair *p) ALLOC_GROW(rename_src, rename_src_nr + 1, rename_src_alloc); rename_src_nr++; if (first < rename_src_nr) - memmove(rename_src + first + 1, rename_src + first, - (rename_src_nr - first - 1) * sizeof(*rename_src)); + MOVE_ARRAY(rename_src + first + 1, rename_src + first, + rename_src_nr - first - 1); rename_src[first].p = p; rename_src[first].score = score; return &(rename_src[first]); |