]> gitweb.factorcode.org Git - factor.git/commit
Fix bugs in heap-delete
authorSamuel Tardieu <sam@rfc1149.net>
Fri, 4 Jan 2019 15:15:45 +0000 (16:15 +0100)
committerJohn Benediktsson <mrjbq7@gmail.com>
Fri, 4 Jan 2019 15:27:28 +0000 (07:27 -0800)
commit2cfa457258d93ea14a132a256fc96cf5c8d95c92
tree41e2cf9372ba3266b79d76abea55c5e2ccde0e10
parent2d0e7163629647d9646178a3d346f92177e99687
Fix bugs in heap-delete

When an entry is kept to be use later with `heap-delete`, its `index`
in the owning heap is automatically updated as the entry sifts up
or down.

However, if the entry is removed from the heap via either a `heap-pop`
or a `heap-delete` operation, its index is not invalidated and
the entry can still be used later with `heap-delete` and remove the
wrong element from the heap.

This patch invalidates entries when they leave the heap by setting
their index to `f`, and check the index in `entry>index`.
basis/heaps/heaps-tests.factor
basis/heaps/heaps.factor