]> git.eshelyaron.com Git - emacs.git/commit
Stop reading and writing the itree_null.parent field entirely.
authorMatt Armstrong <matt@rfc20.org>
Mon, 10 Oct 2022 17:45:05 +0000 (10:45 -0700)
committerMatt Armstrong <matt@rfc20.org>
Tue, 11 Oct 2022 02:37:51 +0000 (19:37 -0700)
commitda0387f0fe79f577fae6d5453c758f600e1ae495
tree12aad28099e8718644f7d831202df266306f92fd
parenta154259bfacf7f1406794a952e80a8197b9a83fb
Stop reading and writing the itree_null.parent field entirely.

With this change all fields in the itree_null sentinel are read only.
This makes accessing itree_null thread safe in an obvious way.

Because it took two commits from two peole to get this right, I think
we can call this design fragile and difficult to reason about.
Another benefit of this commit is as preparation for removing sentinel
node completely, and just using NULL.

* src/itree.c (itree_null): Statically initialize itree_null.parent to
NULL.  It is never accessed.
(null_is_sane): Assert parent == NULL.
(interval_tree_remove_fix): Remove unecessary assignments to parent
from node->parent.  These were the last places itree_null.parent were
read.
(interval_tree_remove): Avoid an assignment to itree_null.parent
through min->right->parent.
(interval_tree_transplant): Avoid an assignment to itree_null.parent
through source->parent.
src/itree.c