Re:Writing a simple pool allocator in C
by harrison_clarke on Thursday January 09, 2025 @04:12PM
(#42649833)
why would you need to iterate on destruction? you free the whole pool at once, since you allocate it all at once
For the `LinkedPtr` list, the bad case is only hit during the destruction of the pool, and then only if you allocate a lot of memory. And given the overhead of deallocation I'm not sure the array approach would measurably help.
I don't see anywhere a binary tree search would be useful here, since there are no loops used for lookup (on allocation they're pushed in order, but when freed chunks are pushed in arbitrary order; this does mean no double-free protection).