diff options
author | René Scharfe <l.s.r@web.de> | 2023-01-02 00:16:48 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-01-09 07:28:36 +0300 |
commit | 6e578410960d9ceb35ec98ad4b6fc711f1a9c85c (patch) | |
tree | eda5b7fabcc2394e6b9b3f021d8e03a0833273fe /pathspec.c | |
parent | d2ec87a684e2f9cd1f0c653620a00d74ad5ee2ce (diff) |
use DUP_ARRAY
Add a semantic patch for replace ALLOC_ARRAY+COPY_ARRAY with DUP_ARRAY
to reduce code duplication and apply its results.
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'pathspec.c')
-rw-r--r-- | pathspec.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/pathspec.c b/pathspec.c index 46e77a85fe..e038481dc4 100644 --- a/pathspec.c +++ b/pathspec.c @@ -681,8 +681,7 @@ void copy_pathspec(struct pathspec *dst, const struct pathspec *src) int i, j; *dst = *src; - ALLOC_ARRAY(dst->items, dst->nr); - COPY_ARRAY(dst->items, src->items, dst->nr); + DUP_ARRAY(dst->items, src->items, dst->nr); for (i = 0; i < dst->nr; i++) { struct pathspec_item *d = &dst->items[i]; @@ -691,8 +690,7 @@ void copy_pathspec(struct pathspec *dst, const struct pathspec *src) d->match = xstrdup(s->match); d->original = xstrdup(s->original); - ALLOC_ARRAY(d->attr_match, d->attr_match_nr); - COPY_ARRAY(d->attr_match, s->attr_match, d->attr_match_nr); + DUP_ARRAY(d->attr_match, s->attr_match, d->attr_match_nr); for (j = 0; j < d->attr_match_nr; j++) { const char *value = s->attr_match[j].value; d->attr_match[j].value = xstrdup_or_null(value); |