qAllocMore is used by growing containers to allocate additional memory
for future growth. The previous algorithm would grow linearly in
increments of 8 up to 64 and then progress exponentially in powers of
two.
The new (constant time) algorithm does away with the linear segment and
always progresses exponentially. It also has the nice benefit of cleanly
avoiding undefined behaviour that the old implementation tried hard to
circumvent.
Besides always progressing exponentially, the next-power-of-two
algorithm was tweaked to always include space for growth. Previously
queries at boundary values (powers of two) would return the same value.
The test was updated to verify sanity of results. As the algorithm is
well behaved, testing of bogus data was dropped. Whatever happens in
those cases is irrelevant, anyway: the bug lives elsewhere.
Change-Id: I4def473cce4b438734887084e3c3bd8da0ff466b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>