diff options
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 () | |||
| 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. */ | ||
| 1231 | void | ||
| 1232 | r_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 | /*********************************************************************** |