]> granicus.if.org Git - git/commitdiff
ewah/bitmap: always allocate 2 more words
authorJeff King <peff@peff.net>
Fri, 13 Sep 2019 13:02:20 +0000 (15:02 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 13 Sep 2019 21:40:33 +0000 (14:40 -0700)
In a following patch we will allocate a variable number
of words in some bitmaps. When iterating over the words we
will need a mark to tell us when to stop iterating. Let's
always allocate 2 more words, that will always contain 0,
as that mark.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
ewah/bitmap.c

index 143dc714196b26b70eb28071957d2723d2415237..eac05485f1c44ad58e804eb7ce9b28610f3c3ac0 100644 (file)
@@ -41,7 +41,7 @@ void bitmap_set(struct bitmap *self, size_t pos)
 
        if (block >= self->word_alloc) {
                size_t old_size = self->word_alloc;
-               self->word_alloc = block * 2;
+               self->word_alloc = (block + 1) * 2;
                REALLOC_ARRAY(self->words, self->word_alloc);
                memset(self->words + old_size, 0x0,
                        (self->word_alloc - old_size) * sizeof(eword_t));