Skip to content

Commit 337ce24

Browse files
Dmitry S. Dolzhenkogitster
authored andcommitted
diffcore-rename.c: use ALLOC_GROW()
Use ALLOC_GROW() instead of open-coding it in locate_rename_dst() and register_rename_src(). Signed-off-by: Dmitry S. Dolzhenko <dmitrys.dolzhenko@yandex.ru> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 4c960a4 commit 337ce24

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

diffcore-rename.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,7 @@ static struct diff_rename_dst *locate_rename_dst(struct diff_filespec *two,
3838
if (!insert_ok)
3939
return NULL;
4040
/* insert to make it at "first" */
41-
if (rename_dst_alloc <= rename_dst_nr) {
42-
rename_dst_alloc = alloc_nr(rename_dst_alloc);
43-
rename_dst = xrealloc(rename_dst,
44-
rename_dst_alloc * sizeof(*rename_dst));
45-
}
41+
ALLOC_GROW(rename_dst, rename_dst_nr + 1, rename_dst_alloc);
4642
rename_dst_nr++;
4743
if (first < rename_dst_nr)
4844
memmove(rename_dst + first + 1, rename_dst + first,
@@ -82,11 +78,7 @@ static struct diff_rename_src *register_rename_src(struct diff_filepair *p)
8278
}
8379

8480
/* insert to make it at "first" */
85-
if (rename_src_alloc <= rename_src_nr) {
86-
rename_src_alloc = alloc_nr(rename_src_alloc);
87-
rename_src = xrealloc(rename_src,
88-
rename_src_alloc * sizeof(*rename_src));
89-
}
81+
ALLOC_GROW(rename_src, rename_src_nr + 1, rename_src_alloc);
9082
rename_src_nr++;
9183
if (first < rename_src_nr)
9284
memmove(rename_src + first + 1, rename_src + first,

0 commit comments

Comments
 (0)