diff options
author | Junio C Hamano <gitster@pobox.com> | 2022-07-18 22:31:53 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-07-18 22:31:53 +0200 |
commit | f01315ef7d8144ca06cd8f3fdbd6c9563e815e89 (patch) | |
tree | 1b77e473f645758f693be2a00149d0d7b3707d77 /builtin/mv.c | |
parent | Merge branch 'fr/vimdiff-layout-fix' (diff) | |
parent | builtin/mv.c: use the MOVE_ARRAY() macro instead of memmove() (diff) | |
download | git-f01315ef7d8144ca06cd8f3fdbd6c9563e815e89.tar.xz git-f01315ef7d8144ca06cd8f3fdbd6c9563e815e89.zip |
Merge branch 'jc/builtin-mv-move-array'
Apply Coccinelle rule to turn raw memmove() into MOVE_ARRAY() cpp
macro, which would improve maintainability and readability.
* jc/builtin-mv-move-array:
builtin/mv.c: use the MOVE_ARRAY() macro instead of memmove()
Diffstat (limited to 'builtin/mv.c')
-rw-r--r-- | builtin/mv.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/builtin/mv.c b/builtin/mv.c index 2a38e2af46..4729bb1a1a 100644 --- a/builtin/mv.c +++ b/builtin/mv.c @@ -187,7 +187,8 @@ int cmd_mv(int argc, const char **argv, const char *prefix) die(_("index file corrupt")); source = internal_prefix_pathspec(prefix, argv, argc, 0); - modes = xcalloc(argc, sizeof(enum update_mode)); + CALLOC_ARRAY(modes, argc); + /* * Keep trailing slash, needed to let * "git mv file no-such-dir/" error out, except in the case @@ -376,14 +377,11 @@ act_on_entry: remove_entry: if (--argc > 0) { int n = argc - i; - memmove(source + i, source + i + 1, - n * sizeof(char *)); - memmove(destination + i, destination + i + 1, - n * sizeof(char *)); - memmove(modes + i, modes + i + 1, - n * sizeof(enum update_mode)); - memmove(submodule_gitfile + i, submodule_gitfile + i + 1, - n * sizeof(char *)); + MOVE_ARRAY(source + i, source + i + 1, n); + MOVE_ARRAY(destination + i, destination + i + 1, n); + MOVE_ARRAY(modes + i, modes + i + 1, n); + MOVE_ARRAY(submodule_gitfile + i, + submodule_gitfile + i + 1, n); i--; } } |