aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer.c
diff options
context:
space:
mode:
authorStefan Monnier2012-10-11 16:32:11 -0400
committerStefan Monnier2012-10-11 16:32:11 -0400
commit389a94a53dfc947c5dc9964b5617e0098513bbe0 (patch)
tree362bd061a49ac61ef83eb38d0df9a33ae1545cb6 /src/buffer.c
parentd8cc4c00eaf27d0151ed4f0f4c40100c099ae0ef (diff)
downloademacs-389a94a53dfc947c5dc9964b5617e0098513bbe0.tar.gz
emacs-389a94a53dfc947c5dc9964b5617e0098513bbe0.zip
* src/buffer.c (Fkill_buffer): Null out the overlay list(s) as well.
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 425d05ca790..9564e91c10c 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -897,6 +897,8 @@ delete_all_overlays (struct buffer *b)
897{ 897{
898 struct Lisp_Overlay *ov, *next; 898 struct Lisp_Overlay *ov, *next;
899 899
900 /* FIXME: Since each drop_overlay will scan BUF_MARKERS to unlink its
901 markers, we have an unneeded O(N^2) behavior here. */
900 for (ov = b->overlays_before; ov; ov = next) 902 for (ov = b->overlays_before; ov; ov = next)
901 { 903 {
902 drop_overlay (b, ov); 904 drop_overlay (b, ov);
@@ -1886,16 +1888,19 @@ cleaning up all windows currently displaying the buffer to be killed. */)
1886 1888
1887 if (b->base_buffer) 1889 if (b->base_buffer)
1888 { 1890 {
1889 /* Unchain all markers that belong to this indirect buffer. 1891 { /* Unchain all markers that belong to this indirect buffer.
1890 Don't unchain the markers that belong to the base buffer 1892 Don't unchain the markers that belong to the base buffer
1891 or its other indirect buffers. */ 1893 or its other indirect buffers. */
1892 for (m = BUF_MARKERS (b); m; ) 1894 struct Lisp_Marker **mp;
1893 { 1895 for (mp = &BUF_MARKERS (b); *mp; )
1894 struct Lisp_Marker *next = m->next; 1896 {
1895 if (m->buffer == b) 1897 struct Lisp_Marker *m = *mp;
1896 unchain_marker (m); 1898 if (m->buffer == b)
1897 m = next; 1899 *mp = m->next;
1898 } 1900 else
1901 mp = &m->next;
1902 }
1903 }
1899 } 1904 }
1900 else 1905 else
1901 { 1906 {
@@ -1911,8 +1916,12 @@ cleaning up all windows currently displaying the buffer to be killed. */)
1911 BUF_MARKERS (b) = NULL; 1916 BUF_MARKERS (b) = NULL;
1912 set_buffer_intervals (b, NULL); 1917 set_buffer_intervals (b, NULL);
1913 1918
1914 /* Perhaps we should explicitly free the interval tree here... */ 1919 /* Perhaps we should explicitly free the interval tree here... */
1915 } 1920 }
1921 /* Since we've unlinked the markers, the overlays can't be here any more
1922 either. */
1923 b->overlays_before = NULL;
1924 b->overlays_after = NULL;
1916 1925
1917 /* Reset the local variables, so that this buffer's local values 1926 /* Reset the local variables, so that this buffer's local values
1918 won't be protected from GC. They would be protected 1927 won't be protected from GC. They would be protected