Fix invalid rounding up to power of two in allocators

#833
This commit is contained in:
Wojtek Figat
2022-11-25 22:07:13 +01:00
parent e6251ea4b0
commit b1618a88be
3 changed files with 8 additions and 8 deletions

View File

@@ -111,8 +111,8 @@ public:
}
else
{
// Round up to the next power of 2 and multiply by 2
capacity++;
// Round up to the next power of 2 and multiply by 2 (http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2)
capacity--;
capacity |= capacity >> 1;
capacity |= capacity >> 2;
capacity |= capacity >> 4;