Skip to content

Commit 4c960a4

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

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

diff.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,11 +1361,7 @@ static struct diffstat_file *diffstat_add(struct diffstat_t *diffstat,
13611361
{
13621362
struct diffstat_file *x;
13631363
x = xcalloc(sizeof (*x), 1);
1364-
if (diffstat->nr == diffstat->alloc) {
1365-
diffstat->alloc = alloc_nr(diffstat->alloc);
1366-
diffstat->files = xrealloc(diffstat->files,
1367-
diffstat->alloc * sizeof(x));
1368-
}
1364+
ALLOC_GROW(diffstat->files, diffstat->nr + 1, diffstat->alloc);
13691365
diffstat->files[diffstat->nr++] = x;
13701366
if (name_b) {
13711367
x->from_name = xstrdup(name_a);
@@ -3965,11 +3961,7 @@ struct diff_queue_struct diff_queued_diff;
39653961

39663962
void diff_q(struct diff_queue_struct *queue, struct diff_filepair *dp)
39673963
{
3968-
if (queue->alloc <= queue->nr) {
3969-
queue->alloc = alloc_nr(queue->alloc);
3970-
queue->queue = xrealloc(queue->queue,
3971-
sizeof(dp) * queue->alloc);
3972-
}
3964+
ALLOC_GROW(queue->queue, queue->nr + 1, queue->alloc);
39733965
queue->queue[queue->nr++] = dp;
39743966
}
39753967

0 commit comments

Comments
 (0)