Skip to content

Commit

Permalink
diff.c: use ALLOC_GROW()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Dmitry S. Dolzhenko authored and Junio C Hamano committed Mar 3, 2014
1 parent d6e82b5 commit 4c960a4
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -1361,11 +1361,7 @@ static struct diffstat_file *diffstat_add(struct diffstat_t *diffstat,
{
struct diffstat_file *x;
x = xcalloc(sizeof (*x), 1);
if (diffstat->nr == diffstat->alloc) {
diffstat->alloc = alloc_nr(diffstat->alloc);
diffstat->files = xrealloc(diffstat->files,
diffstat->alloc * sizeof(x));
}
ALLOC_GROW(diffstat->files, diffstat->nr + 1, diffstat->alloc);
diffstat->files[diffstat->nr++] = x;
if (name_b) {
x->from_name = xstrdup(name_a);
Expand Down Expand Up @@ -3965,11 +3961,7 @@ struct diff_queue_struct diff_queued_diff;

void diff_q(struct diff_queue_struct *queue, struct diff_filepair *dp)
{
if (queue->alloc <= queue->nr) {
queue->alloc = alloc_nr(queue->alloc);
queue->queue = xrealloc(queue->queue,
sizeof(dp) * queue->alloc);
}
ALLOC_GROW(queue->queue, queue->nr + 1, queue->alloc);
queue->queue[queue->nr++] = dp;
}

Expand Down

0 comments on commit 4c960a4

Please sign in to comment.