Re: [RFC PATCH 04/10] ewah/bitmap: always allocate 2 more words
- From
Jeff King <peff@peff.net>
- Date
- Oct 11, 2019, 18:05 UTC
- Message-ID
- <20191011180507.GB20601@sigill.intra.peff.net>
- In-Reply-To
- <CAP8UFD0-NHCj6KcbdMG3bCwWp=wUdoYugLggsbnpvr1d6-P4yg@mail.gmail.com>
On Fri, Oct 11, 2019 at 09:49:53AM +0200, Christian Couder wrote:
Show 7 quoted lines
> > I think this should be squashed with patch 3, adding to that commit > > message "since word_alloc might be 0, we need to change the growth > > function". (Or just make the minimum word_alloc be 1 or 32 or something > > positive, if that's possible.) > > Yeah, thank you for the suggestion. I still wonder why 2 is added > instead of just 1 though.
Yeah, I think it should be squashed. I think it is not intentionally 2, it is just that adding "1" to block makes sure we always make forward progress. It could equally well be:
self->word_alloc = block ? block * 2 : 1;
I think. Or probably this whole thing could be ALLOC_GROW(), as the numbers aren't particularly important. I guess we need to make sure the grown part is zero'd, so probably using alloc_nr() directly would make more sense.
-Peff