]> git.ipfire.org Git - thirdparty/git.git/commitdiff
server-info: drop nr_alloc struct member
authorJeff King <peff@peff.net>
Fri, 5 Apr 2019 18:14:00 +0000 (14:14 -0400)
committerJunio C Hamano <gitster@pobox.com>
Tue, 16 Apr 2019 07:58:21 +0000 (16:58 +0900)
We keep an array of struct pointers, with each one representing a single
packfile. But for some reason there is a nr_alloc parameter inside each
struct, which has never been used.

This is probably cruft left over from development, where we might have
wanted a nr_alloc to dynamically grow the list. But as it turns out, we
do not dynamically grow the list at all, but rather count up the total
number of packs and use that as a maximum size. So while we're thinking
of this, let's add an assert() that documents (and checks!) that our
allocation and fill loops stay in sync.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
server-info.c

index d4115fecbb81346622264dcca61d5260bfb59f41..c9fbfd3a510959b5feaf9c39dc8c23e260245cfe 100644 (file)
@@ -91,7 +91,6 @@ static struct pack_info {
        struct packed_git *p;
        int old_num;
        int new_num;
-       int nr_alloc;
 } **info;
 static int num_pack;
 static const char *objdir;
@@ -213,6 +212,7 @@ static void init_pack_info(const char *infofile, int force)
        for (i = 0, p = get_all_packs(the_repository); p; p = p->next) {
                if (!p->pack_local)
                        continue;
+               assert(i < num_pack);
                info[i] = xcalloc(1, sizeof(struct pack_info));
                info[i]->p = p;
                info[i]->old_num = -1;