aboutsummaryrefslogtreecommitdiffstats
path: root/src/marker.c
diff options
context:
space:
mode:
authorDmitry Antipov2012-07-06 11:34:37 +0400
committerDmitry Antipov2012-07-06 11:34:37 +0400
commit7b7ae96547e53a8ba059186fd0b3fd583e8d41cd (patch)
tree5b5bc00564e76ac9c278ac1978f655fca0d148b7 /src/marker.c
parenta358bac20f90ddbcb46304c77322f07323b9b25d (diff)
downloademacs-7b7ae96547e53a8ba059186fd0b3fd583e8d41cd.tar.gz
emacs-7b7ae96547e53a8ba059186fd0b3fd583e8d41cd.zip
* buffer.c (unchain_overlay): Simplify. Add comment.
* marker.c (unchain_marker): Simplify. Fix comments.
Diffstat (limited to 'src/marker.c')
-rw-r--r--src/marker.c80
1 files changed, 34 insertions, 46 deletions
diff --git a/src/marker.c b/src/marker.c
index 3b0adc7de8d..0a1dd41b498 100644
--- a/src/marker.c
+++ b/src/marker.c
@@ -672,59 +672,47 @@ set_marker_restricted_both (Lisp_Object marker, Lisp_Object buffer, ptrdiff_t ch
672 return marker; 672 return marker;
673} 673}
674 674
675/* Remove MARKER from the chain of whatever buffer it is in. 675/* Remove MARKER from the chain of whatever buffer it is in,
676 Leave it "in no buffer". 676 leaving it points to nowhere. This is called during garbage
677 677 collection, so we must be careful to ignore and preserve
678 This is called during garbage collection, 678 mark bits, including those in chain fields of markers. */
679 so we must be careful to ignore and preserve mark bits,
680 including those in chain fields of markers. */
681 679
682void 680void
683unchain_marker (register struct Lisp_Marker *marker) 681unchain_marker (register struct Lisp_Marker *marker)
684{ 682{
685 register struct Lisp_Marker *tail, *prev, *next; 683 register struct buffer *b = marker->buffer;
686 register struct buffer *b;
687
688 b = marker->buffer;
689 if (b == 0)
690 return;
691
692 if (EQ (BVAR (b, name), Qnil))
693 abort ();
694 684
695 marker->buffer = 0; 685 if (b)
696
697 tail = BUF_MARKERS (b);
698 prev = NULL;
699 while (tail)
700 { 686 {
701 next = tail->next; 687 register struct Lisp_Marker *tail, **prev;
702 688
703 if (marker == tail) 689 /* No dead buffers here. */
704 { 690 eassert (!NILP (BVAR (b, name)));
705 if (!prev) 691
706 { 692 marker->buffer = NULL;
707 BUF_MARKERS (b) = next; 693 prev = &BUF_MARKERS (b);
708 /* Deleting first marker from the buffer's chain. Crash 694
709 if new first marker in chain does not say it belongs 695 for (tail = BUF_MARKERS (b); tail; prev = &tail->next, tail = *prev)
710 to the same buffer, or at least that they have the same 696 if (marker == tail)
711 base buffer. */ 697 {
712 if (next && b->text != next->buffer->text) 698 if (*prev == BUF_MARKERS (b))
713 abort (); 699 {
714 } 700 /* Deleting first marker from the buffer's chain. Crash
715 else 701 if new first marker in chain does not say it belongs
716 prev->next = next; 702 to the same buffer, or at least that they have the same
717 /* We have removed the marker from the chain; 703 base buffer. */
718 no need to scan the rest of the chain. */ 704 if (tail->next && b->text != tail->next->buffer->text)
719 return; 705 abort ();
720 } 706 }
721 else 707 *prev = tail->next;
722 prev = tail; 708 /* We have removed the marker from the chain;
723 tail = next; 709 no need to scan the rest of the chain. */
710 break;
711 }
712
713 /* Error if marker was not in it's chain. */
714 eassert (tail != NULL);
724 } 715 }
725
726 /* Marker was not in its chain. */
727 abort ();
728} 716}
729 717
730/* Return the char position of marker MARKER, as a C integer. */ 718/* Return the char position of marker MARKER, as a C integer. */