summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorDmitry S. Dolzhenko <dmitrys.dolzhenko@yandex.ru>2014-03-03 22:31:53 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-03-03 22:48:39 (GMT)
commit4c960a432cac32a76764c5970e323c294153cec7 (patch)
tree26054318037fea9fe588157437400c0229a11574 /diff.c
parentd6e82b575a7dc16be03f67fc3c4b648bc18df09f (diff)
downloadgit-4c960a432cac32a76764c5970e323c294153cec7.zip
git-4c960a432cac32a76764c5970e323c294153cec7.tar.gz
git-4c960a432cac32a76764c5970e323c294153cec7.tar.bz2
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>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c12
1 files changed, 2 insertions, 10 deletions
diff --git a/diff.c b/diff.c
index 8e4a6a9..f5f0fd1 100644
--- a/diff.c
+++ b/diff.c
@@ -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);
@@ -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;
}