summaryrefslogtreecommitdiff
path: root/pack-revindex.c
diff options
context:
space:
mode:
Diffstat (limited to 'pack-revindex.c')
-rw-r--r--pack-revindex.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/pack-revindex.c b/pack-revindex.c
index b4d2b35bb3..40785f754d 100644
--- a/pack-revindex.c
+++ b/pack-revindex.c
@@ -40,23 +40,25 @@ static int pack_revindex_ix(struct packed_git *p)
return -1 - i;
}
+static int init_pack_revindex_fn(struct packed_git *p, void *data)
+{
+ /* revindex elements are lazily initialized */
+ int num = pack_revindex_ix(p);
+ num = -1 - num;
+ pack_revindex[num].p = p;
+ return 0;
+}
+
static void init_pack_revindex(void)
{
int num;
- struct packed_git *p;
- for (num = 0, p = packed_git; p; p = p->next)
- num++;
+ num = packed_git_count();
if (!num)
return;
pack_revindex_hashsz = num * 11;
pack_revindex = xcalloc(sizeof(*pack_revindex), pack_revindex_hashsz);
- for (p = packed_git; p; p = p->next) {
- num = pack_revindex_ix(p);
- num = - 1 - num;
- pack_revindex[num].p = p;
- }
- /* revindex elements are lazily initialized */
+ foreach_packed_git(init_pack_revindex_fn, NULL, NULL);
}
/*