Commit d48dd7ef authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

usp10: Use usp10_array_reserve() in computeBracketPairs().

parent 24f64acc
......@@ -694,6 +694,7 @@ static BracketPair *computeBracketPairs(IsolatedRun *iso_run)
int stack_top = iso_run->length;
unsigned int pair_count = 0;
BracketPair *out = NULL;
SIZE_T out_size = 0;
int i;
open_stack = heap_alloc(iso_run->length * sizeof(*open_stack));
......@@ -702,54 +703,52 @@ static BracketPair *computeBracketPairs(IsolatedRun *iso_run)
for (i = 0; i < iso_run->length; i++)
{
unsigned short ubv = get_table_entry(bidi_bracket_table, iso_run->item[i].ch);
if (ubv)
{
if (!out)
{
out = heap_alloc(sizeof(*out));
out[0].start = -1;
}
if (!ubv)
continue;
if ((ubv >> 8) == 0)
{
stack_top --;
--stack_top;
open_stack[stack_top] = iso_run->item[i].ch + (signed char)(ubv & 0xff);
/* deal with canonical equivalent U+2329/232A and U+3008/3009 */
if (open_stack[stack_top] == 0x232A)
/* Deal with canonical equivalent U+2329/232A and U+3008/3009. */
if (open_stack[stack_top] == 0x232a)
open_stack[stack_top] = 0x3009;
stack_index[stack_top] = i;
}
else if ((ubv >> 8) == 1)
{
int j;
if (stack_top == iso_run->length) continue;
for (j = stack_top; j < iso_run->length; j++)
unsigned int j;
for (j = stack_top; j < iso_run->length; ++j)
{
WCHAR c = iso_run->item[i].ch;
if (c == 0x232A) c = 0x3009;
if (c == open_stack[j])
{
if (c == 0x232a)
c = 0x3009;
if (c != open_stack[j])
continue;
if (!(usp10_array_reserve((void **)&out, &out_size, pair_count + 2, sizeof(*out))))
ERR("Failed to grow output array.\n");
out[pair_count].start = stack_index[j];
out[pair_count].end = i;
pair_count++;
out = HeapReAlloc(GetProcessHeap(), 0, out, sizeof(BracketPair) * (pair_count+1));
++pair_count;
out[pair_count].start = -1;
stack_top = j+1;
stack_top = j + 1;
break;
}
}
}
}
}
heap_free(open_stack);
heap_free(stack_index);
if (!pair_count)
{
heap_free(out);
return NULL;
}
qsort(out, pair_count, sizeof(*out), compr);
......
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