Open paulbartrum opened 1 year ago
This is true. It fails on allocation N-1. The test is wrong by one. I need to push a fix.
Hello, no fix yet? :)
Strictly as an FYI because I came across this issue when writing a C version of this allocator, there are two easy-to-fix issues here:
allocate
against m_freeOffset
means that node index 0 in the freelist isn't considered valid. Can be fixed in a couple of ways, I just changed it to test m_freeOffset == NO_SPACE
as the invalid case, allowing it to overflow and wrap around after inserting a node into the bin.
Should the
maxAllocs
constructor parameter correspond to the maximum number of timesallocate
can be called? 'Cause if so, it's a bit off I think.Here's a test case:
It fails on the first REQUIRE.
Thanks for open-sourcing this code by the way. I'm testing it out in my C# homebrew engine, it seems to work well so far :-)