[many] Fix many cases of 1 << n exceeding the size of int

Yet again burned by the fack that integer literals are assumed to be of
type int, so `1 << n` is 0 for any n >= 32. This burned me in the frame
allocator, but I also grepped for all instances of `1 <<` and fixed
those too.
This commit is contained in:
Justin C. Miller
2023-02-18 19:53:04 -08:00
parent 42db1e8899
commit 55c88dd943
7 changed files with 20 additions and 19 deletions

View File

@@ -84,7 +84,7 @@ public:
m_nodes(nullptr)
{
if (capacity)
set_capacity(1 << log2(capacity));
set_capacity(1ull << log2(capacity));
}
virtual ~base_map() {

View File

@@ -50,7 +50,7 @@ public:
m_nodes {nullptr}
{
if (capacity) {
m_capacity = 1 << log2(capacity);
m_capacity = 1ull << log2(capacity);
m_nodes = reinterpret_cast<node_type*>(
alloc::allocate(m_capacity * sizeof(node_type)));
for (size_t i = 0; i < m_capacity; ++i)

View File

@@ -265,7 +265,7 @@ public:
void ensure_capacity(count_t size)
{
if (capacity() >= size) return;
count_t capacity = (1 << log2(size));
count_t capacity = (1ull << log2(size));
if (capacity < min_capacity)
capacity = min_capacity;
set_capacity(capacity);