зеркало из https://github.com/microsoft/git.git
Merge branch 'rs/copy-array'
Code clean-up. * rs/copy-array: use COPY_ARRAY for copying arrays coccinelle: use COPY_ARRAY for copying arrays
This commit is contained in:
Коммит
e8d2590641
|
@ -1,29 +1,60 @@
|
|||
@@
|
||||
type T;
|
||||
T *dst;
|
||||
T *src;
|
||||
expression n;
|
||||
expression dst, src, n, E;
|
||||
@@
|
||||
- memcpy(dst, src, (n) * sizeof(*dst));
|
||||
+ COPY_ARRAY(dst, src, n);
|
||||
memcpy(dst, src, n * sizeof(
|
||||
- E[...]
|
||||
+ *(E)
|
||||
))
|
||||
|
||||
@@
|
||||
type T;
|
||||
T *dst;
|
||||
T *src;
|
||||
expression n;
|
||||
T *ptr;
|
||||
T[] arr;
|
||||
expression E, n;
|
||||
@@
|
||||
- memcpy(dst, src, (n) * sizeof(*src));
|
||||
+ COPY_ARRAY(dst, src, n);
|
||||
(
|
||||
memcpy(ptr, E,
|
||||
- n * sizeof(*(ptr))
|
||||
+ n * sizeof(T)
|
||||
)
|
||||
|
|
||||
memcpy(arr, E,
|
||||
- n * sizeof(*(arr))
|
||||
+ n * sizeof(T)
|
||||
)
|
||||
|
|
||||
memcpy(E, ptr,
|
||||
- n * sizeof(*(ptr))
|
||||
+ n * sizeof(T)
|
||||
)
|
||||
|
|
||||
memcpy(E, arr,
|
||||
- n * sizeof(*(arr))
|
||||
+ n * sizeof(T)
|
||||
)
|
||||
)
|
||||
|
||||
@@
|
||||
type T;
|
||||
T *dst;
|
||||
T *src;
|
||||
T *dst_ptr;
|
||||
T *src_ptr;
|
||||
T[] dst_arr;
|
||||
T[] src_arr;
|
||||
expression n;
|
||||
@@
|
||||
- memcpy(dst, src, (n) * sizeof(T));
|
||||
+ COPY_ARRAY(dst, src, n);
|
||||
(
|
||||
- memcpy(dst_ptr, src_ptr, (n) * sizeof(T))
|
||||
+ COPY_ARRAY(dst_ptr, src_ptr, n)
|
||||
|
|
||||
- memcpy(dst_ptr, src_arr, (n) * sizeof(T))
|
||||
+ COPY_ARRAY(dst_ptr, src_arr, n)
|
||||
|
|
||||
- memcpy(dst_arr, src_ptr, (n) * sizeof(T))
|
||||
+ COPY_ARRAY(dst_arr, src_ptr, n)
|
||||
|
|
||||
- memcpy(dst_arr, src_arr, (n) * sizeof(T))
|
||||
+ COPY_ARRAY(dst_arr, src_arr, n)
|
||||
)
|
||||
|
||||
@@
|
||||
type T;
|
||||
|
|
|
@ -644,7 +644,7 @@ static struct tree_content *grow_tree_content(
|
|||
struct tree_content *r = new_tree_content(t->entry_count + amt);
|
||||
r->entry_count = t->entry_count;
|
||||
r->delta_depth = t->delta_depth;
|
||||
memcpy(r->entries,t->entries,t->entry_count*sizeof(t->entries[0]));
|
||||
COPY_ARRAY(r->entries, t->entries, t->entry_count);
|
||||
release_tree_content(t);
|
||||
return r;
|
||||
}
|
||||
|
|
2
kwset.c
2
kwset.c
|
@ -475,7 +475,7 @@ kwsprep (kwset_t kws)
|
|||
for (i = 0; i < NCHAR; ++i)
|
||||
kwset->next[i] = next[U(trans[i])];
|
||||
else
|
||||
memcpy(kwset->next, next, NCHAR * sizeof(struct trie *));
|
||||
COPY_ARRAY(kwset->next, next, NCHAR);
|
||||
}
|
||||
|
||||
/* Fix things up for any translation table. */
|
||||
|
|
|
@ -1272,7 +1272,7 @@ static enum object_type packed_to_object_type(struct repository *r,
|
|||
if (poi_stack_nr >= poi_stack_alloc && poi_stack == small_poi_stack) {
|
||||
poi_stack_alloc = alloc_nr(poi_stack_nr);
|
||||
ALLOC_ARRAY(poi_stack, poi_stack_alloc);
|
||||
memcpy(poi_stack, small_poi_stack, sizeof(off_t)*poi_stack_nr);
|
||||
COPY_ARRAY(poi_stack, small_poi_stack, poi_stack_nr);
|
||||
} else {
|
||||
ALLOC_GROW(poi_stack, poi_stack_nr+1, poi_stack_alloc);
|
||||
}
|
||||
|
@ -1682,8 +1682,8 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
|
|||
&& delta_stack == small_delta_stack) {
|
||||
delta_stack_alloc = alloc_nr(delta_stack_nr);
|
||||
ALLOC_ARRAY(delta_stack, delta_stack_alloc);
|
||||
memcpy(delta_stack, small_delta_stack,
|
||||
sizeof(*delta_stack)*delta_stack_nr);
|
||||
COPY_ARRAY(delta_stack, small_delta_stack,
|
||||
delta_stack_nr);
|
||||
} else {
|
||||
ALLOC_GROW(delta_stack, delta_stack_nr+1, delta_stack_alloc);
|
||||
}
|
||||
|
|
4
pretty.c
4
pretty.c
|
@ -106,8 +106,8 @@ static void setup_commit_formats(void)
|
|||
commit_formats_len = ARRAY_SIZE(builtin_formats);
|
||||
builtin_formats_len = commit_formats_len;
|
||||
ALLOC_GROW(commit_formats, commit_formats_len, commit_formats_alloc);
|
||||
memcpy(commit_formats, builtin_formats,
|
||||
sizeof(*builtin_formats)*ARRAY_SIZE(builtin_formats));
|
||||
COPY_ARRAY(commit_formats, builtin_formats,
|
||||
ARRAY_SIZE(builtin_formats));
|
||||
|
||||
git_config(git_pretty_formats_config, NULL);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче