Merge branch 'sg/cocci-move-array'
Code clean-up. * sg/cocci-move-array: Use MOVE_ARRAY
This commit is contained in:
commit
cbf0240f82
@ -84,9 +84,8 @@ static struct cache_tree_sub *find_subtree(struct cache_tree *it,
|
||||
down->namelen = pathlen;
|
||||
|
||||
if (pos < it->subtree_nr)
|
||||
memmove(it->down + pos + 1,
|
||||
it->down + pos,
|
||||
sizeof(down) * (it->subtree_nr - pos - 1));
|
||||
MOVE_ARRAY(it->down + pos + 1, it->down + pos,
|
||||
it->subtree_nr - pos - 1);
|
||||
it->down[pos] = down;
|
||||
return down;
|
||||
}
|
||||
|
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;
|
||||
}
|
||||
|
@ -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]);
|
||||
|
4
dir.c
4
dir.c
@ -747,8 +747,8 @@ static struct untracked_cache_dir *lookup_untracked(struct untracked_cache *uc,
|
||||
FLEX_ALLOC_MEM(d, name, name, len);
|
||||
|
||||
ALLOC_GROW(dir->dirs, dir->dirs_nr + 1, dir->dirs_alloc);
|
||||
memmove(dir->dirs + first + 1, dir->dirs + first,
|
||||
(dir->dirs_nr - first) * sizeof(*dir->dirs));
|
||||
MOVE_ARRAY(dir->dirs + first + 1, dir->dirs + first,
|
||||
dir->dirs_nr - first);
|
||||
dir->dirs_nr++;
|
||||
dir->dirs[first] = d;
|
||||
return d;
|
||||
|
@ -525,7 +525,7 @@ unknown:
|
||||
|
||||
int parse_options_end(struct parse_opt_ctx_t *ctx)
|
||||
{
|
||||
memmove(ctx->out + ctx->cpidx, ctx->argv, ctx->argc * sizeof(*ctx->out));
|
||||
MOVE_ARRAY(ctx->out + ctx->cpidx, ctx->argv, ctx->argc);
|
||||
ctx->out[ctx->cpidx + ctx->argc] = NULL;
|
||||
return ctx->cpidx + ctx->argc;
|
||||
}
|
||||
|
@ -1217,9 +1217,8 @@ int add_index_entry(struct index_state *istate, struct cache_entry *ce, int opti
|
||||
/* Add it in.. */
|
||||
istate->cache_nr++;
|
||||
if (istate->cache_nr > pos + 1)
|
||||
memmove(istate->cache + pos + 1,
|
||||
istate->cache + pos,
|
||||
(istate->cache_nr - pos - 1) * sizeof(ce));
|
||||
MOVE_ARRAY(istate->cache + pos + 1, istate->cache + pos,
|
||||
istate->cache_nr - pos - 1);
|
||||
set_index_entry(istate, pos, ce);
|
||||
istate->cache_changed |= CE_ENTRY_ADDED;
|
||||
return 0;
|
||||
|
@ -238,10 +238,8 @@ int remove_entry_from_dir(struct ref_dir *dir, const char *refname)
|
||||
return -1;
|
||||
entry = dir->entries[entry_index];
|
||||
|
||||
memmove(&dir->entries[entry_index],
|
||||
&dir->entries[entry_index + 1],
|
||||
(dir->nr - entry_index - 1) * sizeof(*dir->entries)
|
||||
);
|
||||
MOVE_ARRAY(&dir->entries[entry_index],
|
||||
&dir->entries[entry_index + 1], dir->nr - entry_index - 1);
|
||||
dir->nr--;
|
||||
if (dir->sorted > entry_index)
|
||||
dir->sorted--;
|
||||
|
@ -44,10 +44,8 @@ static int register_replace_object(struct replace_object *replace,
|
||||
ALLOC_GROW(replace_object, replace_object_nr + 1, replace_object_alloc);
|
||||
replace_object_nr++;
|
||||
if (pos < replace_object_nr)
|
||||
memmove(replace_object + pos + 1,
|
||||
replace_object + pos,
|
||||
(replace_object_nr - pos - 1) *
|
||||
sizeof(*replace_object));
|
||||
MOVE_ARRAY(replace_object + pos + 1, replace_object + pos,
|
||||
replace_object_nr - pos - 1);
|
||||
replace_object[pos] = replace;
|
||||
return 0;
|
||||
}
|
||||
|
4
rerere.c
4
rerere.c
@ -159,8 +159,8 @@ static struct rerere_dir *find_rerere_dir(const char *hex)
|
||||
ALLOC_GROW(rerere_dir, rerere_dir_nr + 1, rerere_dir_alloc);
|
||||
/* ... and add it in. */
|
||||
rerere_dir_nr++;
|
||||
memmove(rerere_dir + pos + 1, rerere_dir + pos,
|
||||
(rerere_dir_nr - pos - 1) * sizeof(*rerere_dir));
|
||||
MOVE_ARRAY(rerere_dir + pos + 1, rerere_dir + pos,
|
||||
rerere_dir_nr - pos - 1);
|
||||
rerere_dir[pos] = rr_dir;
|
||||
scan_rerere_dir(rr_dir);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user