News for hackers. Stuff that matters.
Re:Writing a simple pool allocator in C by o11c on Wednesday January 08, 2025 @11:54PM (#42641741)
For the `Chunk` list, this isn't one of the cases where linked lists are harmful. Each use only touches the top of the stack, never iterates. Also, linked lists are much easier to make thread-safe.

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).

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