Commit ead6f8f5 authored by Eli Zaretskii's avatar Eli Zaretskii

Fix bug #6210.

 bidi.c (bidi_cache_shrink, bidi_cache_iterator_state): Fix
 reallocation of the cache.
parent 2a96c2a7
2010-05-19 Eli Zaretskii <eliz@gnu.org>
* bidi.c (bidi_cache_shrink, bidi_cache_iterator_state): Fix
reallocation of the cache. (Bug#6210)
2010-05-19 Glenn Morris <rgm@gnu.org>
* s/msdos.h (ORDINARY_LINK): Move to sed2v2.inp.
......
......@@ -543,6 +543,7 @@ bidi_copy_it (struct bidi_it *to, struct bidi_it *from)
#define BIDI_CACHE_CHUNK 200
static struct bidi_it *bidi_cache;
static size_t bidi_cache_size = 0;
static size_t elsz = sizeof (struct bidi_it);
static int bidi_cache_idx; /* next unused cache slot */
static int bidi_cache_last_idx; /* slot of last cache hit */
......@@ -558,8 +559,9 @@ bidi_cache_shrink (void)
{
if (bidi_cache_size > BIDI_CACHE_CHUNK)
{
bidi_cache_size = BIDI_CACHE_CHUNK * sizeof (struct bidi_it);
bidi_cache = (struct bidi_it *) xrealloc (bidi_cache, bidi_cache_size);
bidi_cache_size = BIDI_CACHE_CHUNK;
bidi_cache =
(struct bidi_it *) xrealloc (bidi_cache, bidi_cache_size * elsz);
}
bidi_cache_reset ();
}
......@@ -688,9 +690,9 @@ bidi_cache_iterator_state (struct bidi_it *bidi_it, int resolved)
/* Enlarge the cache as needed. */
if (idx >= bidi_cache_size)
{
bidi_cache_size += BIDI_CACHE_CHUNK * sizeof (struct bidi_it);
bidi_cache_size += BIDI_CACHE_CHUNK;
bidi_cache =
(struct bidi_it *) xrealloc (bidi_cache, bidi_cache_size);
(struct bidi_it *) xrealloc (bidi_cache, bidi_cache_size * elsz);
}
/* Character positions should correspond to cache positions 1:1.
If we are outside the range of cached positions, the cache is
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment