summaryrefslogtreecommitdiff
path: root/reflog-walk.c
diff options
context:
space:
mode:
Diffstat (limited to 'reflog-walk.c')
-rw-r--r--reflog-walk.c24
1 files changed, 8 insertions, 16 deletions
diff --git a/reflog-walk.c b/reflog-walk.c
index b2fbdb2392..9ce8b53ccc 100644
--- a/reflog-walk.c
+++ b/reflog-walk.c
@@ -26,14 +26,10 @@ static int read_one_reflog(unsigned char *osha1, unsigned char *nsha1,
struct complete_reflogs *array = cb_data;
struct reflog_info *item;
- if (array->nr >= array->alloc) {
- array->alloc = alloc_nr(array->nr + 1);
- array->items = xrealloc(array->items, array->alloc *
- sizeof(struct reflog_info));
- }
+ ALLOC_GROW(array->items, array->nr + 1, array->alloc);
item = array->items + array->nr;
- memcpy(item->osha1, osha1, 20);
- memcpy(item->nsha1, nsha1, 20);
+ hashcpy(item->osha1, osha1);
+ hashcpy(item->nsha1, nsha1);
item->email = xstrdup(email);
item->timestamp = timestamp;
item->tz = tz;
@@ -45,7 +41,7 @@ static int read_one_reflog(unsigned char *osha1, unsigned char *nsha1,
static struct complete_reflogs *read_complete_reflog(const char *ref)
{
struct complete_reflogs *reflogs =
- xcalloc(sizeof(struct complete_reflogs), 1);
+ xcalloc(1, sizeof(struct complete_reflogs));
reflogs->ref = xstrdup(ref);
for_each_reflog_ent(ref, read_one_reflog, reflogs);
if (reflogs->nr == 0) {
@@ -114,11 +110,7 @@ static void add_commit_info(struct commit *commit, void *util,
struct commit_info_lifo *lifo)
{
struct commit_info *info;
- if (lifo->nr >= lifo->alloc) {
- lifo->alloc = alloc_nr(lifo->nr + 1);
- lifo->items = xrealloc(lifo->items,
- lifo->alloc * sizeof(struct commit_info));
- }
+ ALLOC_GROW(lifo->items, lifo->nr + 1, lifo->alloc);
info = lifo->items + lifo->nr;
info->commit = commit;
info->util = util;
@@ -143,7 +135,7 @@ struct reflog_walk_info {
void init_reflog_walk(struct reflog_walk_info** info)
{
- *info = xcalloc(sizeof(struct reflog_walk_info), 1);
+ *info = xcalloc(1, sizeof(struct reflog_walk_info));
}
int add_reflog_for_walk(struct reflog_walk_info *info,
@@ -207,7 +199,7 @@ int add_reflog_for_walk(struct reflog_walk_info *info,
= reflogs;
}
- commit_reflog = xcalloc(sizeof(struct commit_reflog), 1);
+ commit_reflog = xcalloc(1, sizeof(struct commit_reflog));
if (recno < 0) {
commit_reflog->recno = get_reflog_recno_by_time(reflogs, timestamp);
if (commit_reflog->recno < 0) {
@@ -250,7 +242,7 @@ void fake_reflog_parent(struct reflog_walk_info *info, struct commit *commit)
return;
}
- commit->parents = xcalloc(sizeof(struct commit_list), 1);
+ commit->parents = xcalloc(1, sizeof(struct commit_list));
commit->parents->item = commit_info->commit;
}