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>
Dmitry S. Dolzhenko committed
Mar 4, 2014 at 02:31 UTC
4c960a432cac32a76764c5970e323c294153cec7
1 file changed
+2
-10
diff.c
+2
-10
@@ -1361,11 +1361,7 @@ static struct diffstat_file *diffstat_add(struct diffstat_t *diffstat,
1361
{
1362
struct diffstat_file *x;
1363
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);
1365
diffstat->files[diffstat->nr++] = x;
1366
if (name_b) {
1367
x->from_name = xstrdup(name_a);
@@ -3965,11 +3961,7 @@ struct diff_queue_struct diff_queued_diff;
3961
3962
void diff_q(struct diff_queue_struct *queue, struct diff_filepair *dp)
3963
{
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);
3965
queue->queue[queue->nr++] = dp;
3966
}
3967