aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Rumney2008-12-24 11:20:32 +0000
committerJason Rumney2008-12-24 11:20:32 +0000
commitbaae5c2d8453b653cb1cffd638d9bd90064d6275 (patch)
tree41bcf421e601d5b290a026005b07d17ea49f21fe /src
parentb08ddfb407a2017fd781fadf6cc2573909a2b664 (diff)
downloademacs-baae5c2d8453b653cb1cffd638d9bd90064d6275.tar.gz
emacs-baae5c2d8453b653cb1cffd638d9bd90064d6275.zip
* ralloc.c (r_alloc_reset_variable): New function.
* buffer.c (Fbuffer_swap_text) [REL_ALLOC]: Reset ralloc's internal record of what points where.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog7
-rw-r--r--src/buffer.c11
-rw-r--r--src/ralloc.c28
3 files changed, 46 insertions, 0 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index e7d44c35b51..56bb534e457 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,10 @@
12008-12-24 Jason Rumney <jasonr@gnu.org>
2
3 * ralloc.c (r_alloc_reset_variable): New function.
4
5 * buffer.c (Fbuffer_swap_text) [REL_ALLOC]: Reset ralloc's internal
6 record of what points where.
7
12008-12-22 Dan Nicolaescu <dann@ics.uci.edu> 82008-12-22 Dan Nicolaescu <dann@ics.uci.edu>
2 9
3 * minibuf.c (read_minibuf): Follow the non-interactive case when 10 * minibuf.c (read_minibuf): Follow the non-interactive case when
diff --git a/src/buffer.c b/src/buffer.c
index 110cb4f7faf..33667b79ead 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -2182,6 +2182,10 @@ advance_to_char_boundary (byte_pos)
2182 return byte_pos; 2182 return byte_pos;
2183} 2183}
2184 2184
2185#ifdef REL_ALLOC
2186extern void r_alloc_reset_variable P_ ((PTR *, PTR *));
2187#endif /* REL_ALLOC */
2188
2185DEFUN ("buffer-swap-text", Fbuffer_swap_text, Sbuffer_swap_text, 2189DEFUN ("buffer-swap-text", Fbuffer_swap_text, Sbuffer_swap_text,
2186 1, 1, 0, 2190 1, 1, 0,
2187 doc: /* Swap the text between current buffer and BUFFER. */) 2191 doc: /* Swap the text between current buffer and BUFFER. */)
@@ -2223,6 +2227,13 @@ DEFUN ("buffer-swap-text", Fbuffer_swap_text, Sbuffer_swap_text,
2223 swapfield (own_text, struct buffer_text); 2227 swapfield (own_text, struct buffer_text);
2224 eassert (current_buffer->text == &current_buffer->own_text); 2228 eassert (current_buffer->text == &current_buffer->own_text);
2225 eassert (other_buffer->text == &other_buffer->own_text); 2229 eassert (other_buffer->text == &other_buffer->own_text);
2230#ifdef REL_ALLOC
2231 r_alloc_reset_variable ((PTR *) &current_buffer->own_text.beg,
2232 (PTR *) &other_buffer->own_text.beg);
2233 r_alloc_reset_variable ((PTR *) &other_buffer->own_text.beg,
2234 (PTR *) &current_buffer->own_text.beg);
2235#endif /* REL_ALLOC */
2236
2226 swapfield (pt, EMACS_INT); 2237 swapfield (pt, EMACS_INT);
2227 swapfield (pt_byte, EMACS_INT); 2238 swapfield (pt_byte, EMACS_INT);
2228 swapfield (begv, EMACS_INT); 2239 swapfield (begv, EMACS_INT);
diff --git a/src/ralloc.c b/src/ralloc.c
index 30ed888697f..61f7aff95f5 100644
--- a/src/ralloc.c
+++ b/src/ralloc.c
@@ -1223,6 +1223,34 @@ r_alloc_check ()
1223 1223
1224#endif /* DEBUG */ 1224#endif /* DEBUG */
1225 1225
1226/* Update the internal record of which variable points to some data to NEW.
1227 Used by buffer-swap-text in Emacs to restore consistency after it
1228 swaps the buffer text between two buffer objects. The OLD pointer
1229 is checked to ensure that memory corruption does not occur due to
1230 misuse. */
1231void
1232r_alloc_reset_variable (old, new)
1233 POINTER *old, *new;
1234{
1235 bloc_ptr bloc = first_bloc;
1236
1237 /* Find the bloc that corresponds to the data pointed to by pointer.
1238 find_bloc cannot be used, as it has internal consistency checks
1239 which fail when the variable needs reseting. */
1240 while (bloc != NIL_BLOC)
1241 {
1242 if (bloc->data == *new)
1243 break;
1244
1245 bloc = bloc->next;
1246 }
1247
1248 if (bloc == NIL_BLOC || bloc->variable != old)
1249 abort ();
1250
1251 /* Update variable to point to the new location. */
1252 bloc->variable = new;
1253}
1226 1254
1227 1255
1228/*********************************************************************** 1256/***********************************************************************