diff options
author | Jason Rumney <jasonr@gnu.org> | 2008-12-24 11:20:32 +0000 |
---|---|---|
committer | Jason Rumney <jasonr@gnu.org> | 2008-12-24 11:20:32 +0000 |
commit | baae5c2d8453b653cb1cffd638d9bd90064d6275 (patch) | |
tree | 41bcf421e601d5b290a026005b07d17ea49f21fe /src/ralloc.c | |
parent | b08ddfb407a2017fd781fadf6cc2573909a2b664 (diff) | |
download | emacs-baae5c2d8453b653cb1cffd638d9bd90064d6275.tar.gz |
* 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/ralloc.c')
-rw-r--r-- | src/ralloc.c | 28 |
1 files changed, 28 insertions, 0 deletions
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 () #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; +} /*********************************************************************** |