mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 08:24:32 -08:00
[kutil] Fix a bug with order ignoring header size
When moving heap allocation order calculation to use __builtin_clz, we based that calculation off of the length requested, not the totla length including the memory header size.
This commit is contained in:
@@ -77,7 +77,9 @@ heap_allocator::allocate(size_t length)
|
||||
if (length == 0)
|
||||
return nullptr;
|
||||
|
||||
unsigned order = 64 - __builtin_clz(length);
|
||||
const unsigned clz = __builtin_clzll(total);
|
||||
const unsigned order = 64 - clz;
|
||||
|
||||
kassert(order <= max_order, "Tried to allocate a block bigger than max_order");
|
||||
if (order > max_order)
|
||||
return nullptr;
|
||||
|
||||
Reference in New Issue
Block a user