aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer.c
diff options
context:
space:
mode:
authorStefan Monnier2022-11-18 11:11:46 -0500
committerStefan Monnier2022-11-18 11:11:46 -0500
commit5525bd39322a66cf4133a2593d6349e4d75d8b6a (patch)
treef02d16a37f1a8971101b1257ec3065642c9cc40b /src/buffer.c
parent985ec6b26ebd724ff0e7d1045d2c315df3d3c05c (diff)
downloademacs-5525bd39322a66cf4133a2593d6349e4d75d8b6a.tar.gz
emacs-5525bd39322a66cf4133a2593d6349e4d75d8b6a.zip
itree: Make sure a deleted overlay has NULL pointer fields
* src/buffer.c (delete_all_overlays): Use POST_ORDER to set the node's pointers to NULL, as god intended. * src/itree.c (itree_insert_node): Uncomment the assertion accordingly.
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 4da5b451d0f..d948aaa2662 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -937,19 +937,16 @@ delete_all_overlays (struct buffer *b)
937 if (! b->overlays) 937 if (! b->overlays)
938 return; 938 return;
939 939
940 /* FIXME: This loop sets the overlays' `buffer` field to NULL but 940 /* The general rule is that the tree cannot be modified from within
941 doesn't set the itree_nodes' `parent`, `left` and `right` 941 ITREE_FOREACH, but here we bend this rule a little because we know
942 fields accordingly. I believe it's harmless, but a bit untidy since 942 that the POST_ORDER iterator will not need to look at `node` again. */
943 other parts of the code are careful to set those fields to NULL when 943 ITREE_FOREACH (node, b->overlays, PTRDIFF_MIN, PTRDIFF_MAX, POST_ORDER)
944 the overlay is deleted.
945 Of course, we can't set them to NULL from within the iteration
946 because the iterator may need them (tho we could if we added
947 an ITREE_POST_ORDER iteration order). */
948 ITREE_FOREACH (node, b->overlays, PTRDIFF_MIN, PTRDIFF_MAX, ASCENDING)
949 { 944 {
950 modify_overlay (b, node->begin, node->end); 945 modify_overlay (b, node->begin, node->end);
951 /* Where are the nodes freed ? --ap */
952 XOVERLAY (node->data)->buffer = NULL; 946 XOVERLAY (node->data)->buffer = NULL;
947 node->parent = NULL;
948 node->left = NULL;
949 node->right = NULL;
953 } 950 }
954 itree_clear (b->overlays); 951 itree_clear (b->overlays);
955} 952}