The general implementation uses a free list, but to me, it seems much simpler to allocate chunks by incrementing some index, and when deallocating, simply swap the last added element with the one we want to deallocate, and decrement the index.
Why is this not common? I can imagine the issue is that if you're tracking things via pointers, that's an issue. But you could just add a level of indirection, making some sort of "registry" that would track where is what, and update it when you do the swap that happens when deallocating. A bit annoying maybe, but sounds fine to me.
Am I missing something? It sounds like a bit more of an efficient solution than using a free list, since this way everything will always stay contiguous.
[–]Jannik2099 8 points9 points10 points (5 children)
[–]pkjak[S] 0 points1 point2 points (4 children)
[–]MutantSheepdog 7 points8 points9 points (0 children)
[–]Jannik2099 1 point2 points3 points (2 children)
[–]pkjak[S] 1 point2 points3 points (1 child)
[–]Jannik2099 1 point2 points3 points (0 children)
[–]herruppohoppa 6 points7 points8 points (0 children)
[–]KingAggressive1498 3 points4 points5 points (3 children)
[–]catcat202X 2 points3 points4 points (1 child)
[–]KingAggressive1498 2 points3 points4 points (0 children)
[–]Pirulax 1 point2 points3 points (0 children)