diff options
| author | Eli Zaretskii | 2010-05-19 10:22:41 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2010-05-19 10:22:41 +0300 |
| commit | ead6f8f50b3d538902ad33421973be783cbea969 (patch) | |
| tree | 238b2ebc3629fd8d33271e4c6aa989e9f14d5249 /src | |
| parent | 2a96c2a765972b1b9b0a07d109f00396923d510b (diff) | |
| download | emacs-ead6f8f50b3d538902ad33421973be783cbea969.tar.gz emacs-ead6f8f50b3d538902ad33421973be783cbea969.zip | |
Fix bug #6210.
bidi.c (bidi_cache_shrink, bidi_cache_iterator_state): Fix
reallocation of the cache.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 5 | ||||
| -rw-r--r-- | src/bidi.c | 10 |
2 files changed, 11 insertions, 4 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 8a5d5b9fb84..7c59d6b6545 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2010-05-19 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | * bidi.c (bidi_cache_shrink, bidi_cache_iterator_state): Fix | ||
| 4 | reallocation of the cache. (Bug#6210) | ||
| 5 | |||
| 1 | 2010-05-19 Glenn Morris <rgm@gnu.org> | 6 | 2010-05-19 Glenn Morris <rgm@gnu.org> |
| 2 | 7 | ||
| 3 | * s/msdos.h (ORDINARY_LINK): Move to sed2v2.inp. | 8 | * s/msdos.h (ORDINARY_LINK): Move to sed2v2.inp. |
diff --git a/src/bidi.c b/src/bidi.c index dbc95608fea..6bcbf6f6aea 100644 --- a/src/bidi.c +++ b/src/bidi.c | |||
| @@ -543,6 +543,7 @@ bidi_copy_it (struct bidi_it *to, struct bidi_it *from) | |||
| 543 | #define BIDI_CACHE_CHUNK 200 | 543 | #define BIDI_CACHE_CHUNK 200 |
| 544 | static struct bidi_it *bidi_cache; | 544 | static struct bidi_it *bidi_cache; |
| 545 | static size_t bidi_cache_size = 0; | 545 | static size_t bidi_cache_size = 0; |
| 546 | static size_t elsz = sizeof (struct bidi_it); | ||
| 546 | static int bidi_cache_idx; /* next unused cache slot */ | 547 | static int bidi_cache_idx; /* next unused cache slot */ |
| 547 | static int bidi_cache_last_idx; /* slot of last cache hit */ | 548 | static int bidi_cache_last_idx; /* slot of last cache hit */ |
| 548 | 549 | ||
| @@ -558,8 +559,9 @@ bidi_cache_shrink (void) | |||
| 558 | { | 559 | { |
| 559 | if (bidi_cache_size > BIDI_CACHE_CHUNK) | 560 | if (bidi_cache_size > BIDI_CACHE_CHUNK) |
| 560 | { | 561 | { |
| 561 | bidi_cache_size = BIDI_CACHE_CHUNK * sizeof (struct bidi_it); | 562 | bidi_cache_size = BIDI_CACHE_CHUNK; |
| 562 | bidi_cache = (struct bidi_it *) xrealloc (bidi_cache, bidi_cache_size); | 563 | bidi_cache = |
| 564 | (struct bidi_it *) xrealloc (bidi_cache, bidi_cache_size * elsz); | ||
| 563 | } | 565 | } |
| 564 | bidi_cache_reset (); | 566 | bidi_cache_reset (); |
| 565 | } | 567 | } |
| @@ -688,9 +690,9 @@ bidi_cache_iterator_state (struct bidi_it *bidi_it, int resolved) | |||
| 688 | /* Enlarge the cache as needed. */ | 690 | /* Enlarge the cache as needed. */ |
| 689 | if (idx >= bidi_cache_size) | 691 | if (idx >= bidi_cache_size) |
| 690 | { | 692 | { |
| 691 | bidi_cache_size += BIDI_CACHE_CHUNK * sizeof (struct bidi_it); | 693 | bidi_cache_size += BIDI_CACHE_CHUNK; |
| 692 | bidi_cache = | 694 | bidi_cache = |
| 693 | (struct bidi_it *) xrealloc (bidi_cache, bidi_cache_size); | 695 | (struct bidi_it *) xrealloc (bidi_cache, bidi_cache_size * elsz); |
| 694 | } | 696 | } |
| 695 | /* Character positions should correspond to cache positions 1:1. | 697 | /* Character positions should correspond to cache positions 1:1. |
| 696 | If we are outside the range of cached positions, the cache is | 698 | If we are outside the range of cached positions, the cache is |