Mercurial > emacs
diff src/ralloc.c @ 100673:01f68a925d12
* ralloc.c (r_alloc_reset_variable): New function.
* buffer.c (Fbuffer_swap_text) [REL_ALLOC]: Reset ralloc's internal
record of what points where.
| author | Jason Rumney <jasonr@gnu.org> |
|---|---|
| date | Wed, 24 Dec 2008 11:20:32 +0000 |
| parents | 0d5b71c55b3c |
| children | dbba9cb0e6ce |
line wrap: on
line diff
--- a/src/ralloc.c Wed Dec 24 00:45:51 2008 +0000 +++ b/src/ralloc.c Wed Dec 24 11:20:32 2008 +0000 @@ -1223,6 +1223,34 @@ #endif /* DEBUG */ +/* Update the internal record of which variable points to some data to NEW. + Used by buffer-swap-text in Emacs to restore consistency after it + swaps the buffer text between two buffer objects. The OLD pointer + is checked to ensure that memory corruption does not occur due to + misuse. */ +void +r_alloc_reset_variable (old, new) + POINTER *old, *new; +{ + bloc_ptr bloc = first_bloc; + + /* Find the bloc that corresponds to the data pointed to by pointer. + find_bloc cannot be used, as it has internal consistency checks + which fail when the variable needs reseting. */ + while (bloc != NIL_BLOC) + { + if (bloc->data == *new) + break; + + bloc = bloc->next; + } + + if (bloc == NIL_BLOC || bloc->variable != old) + abort (); + + /* Update variable to point to the new location. */ + bloc->variable = new; +} /***********************************************************************
