Skip to content

Commit 6647cc2

Browse files
Dmitry S. Dolzhenkogitster
authored andcommitted
reflog-walk.c: use ALLOC_GROW()
Use ALLOC_GROW() instead of open-coding it in add_commit_info() and read_one_reflog(). Signed-off-by: Dmitry S. Dolzhenko <dmitrys.dolzhenko@yandex.ru> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 72004b4 commit 6647cc2

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

reflog-walk.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,7 @@ static int read_one_reflog(unsigned char *osha1, unsigned char *nsha1,
2626
struct complete_reflogs *array = cb_data;
2727
struct reflog_info *item;
2828

29-
if (array->nr >= array->alloc) {
30-
array->alloc = alloc_nr(array->nr + 1);
31-
array->items = xrealloc(array->items, array->alloc *
32-
sizeof(struct reflog_info));
33-
}
29+
ALLOC_GROW(array->items, array->nr + 1, array->alloc);
3430
item = array->items + array->nr;
3531
memcpy(item->osha1, osha1, 20);
3632
memcpy(item->nsha1, nsha1, 20);
@@ -114,11 +110,7 @@ static void add_commit_info(struct commit *commit, void *util,
114110
struct commit_info_lifo *lifo)
115111
{
116112
struct commit_info *info;
117-
if (lifo->nr >= lifo->alloc) {
118-
lifo->alloc = alloc_nr(lifo->nr + 1);
119-
lifo->items = xrealloc(lifo->items,
120-
lifo->alloc * sizeof(struct commit_info));
121-
}
113+
ALLOC_GROW(lifo->items, lifo->nr + 1, lifo->alloc);
122114
info = lifo->items + lifo->nr;
123115
info->commit = commit;
124116
info->util = util;

0 commit comments

Comments
 (0)