fitzgen / generational-arena

A safe arena allocator that allows deletion without suffering from the ABA problem by using generational indices.
https://docs.rs/generational-arena
Mozilla Public License 2.0
672 stars 53 forks source link

Fix panic and generation issue in Arena::drain() #45

Closed taiki-e closed 3 years ago

taiki-e commented 3 years ago

This fixes the second and fourth issues of #30.

  1. If you add some elements and then use Arena::drain(), again, this should bump the generation and it doesn't, which is a similar bug.

  2. drain() doesn't fix up the free list or other state. After you drain the whole arena, is still has a positive len(). Then you'll get asserts when you try to use the arena. I'm not sure what exactly will be involved to fix this.