[kutil] Fix failing heap allocator tests

The tests clearly haven't even been built in a while. I've added a
helper script to the project root. Also added a kassert() handler that
will allow tests to catch or fail on asserts.
This commit is contained in:
2020-09-07 16:56:07 -07:00
parent 8534d8d3c5
commit 8490472581
6 changed files with 72 additions and 10 deletions

View File

@@ -77,8 +77,10 @@ heap_allocator::allocate(size_t length)
if (length == 0)
return nullptr;
const unsigned clz = __builtin_clzll(total);
const unsigned order = 64 - clz;
const unsigned clz = __builtin_clzll(total - 1);
unsigned order = 64 - clz;
if (order < min_order)
order = min_order;
kassert(order <= max_order, "Tried to allocate a block bigger than max_order");
if (order > max_order)