From ed7a8821e38d5a5fdd64f0f5cfca6cf89e331ca1 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 15 Apr 2014 22:59:25 -0700 Subject: [PATCH 06/12] dfa: simplify multibyte_prop allocation * src/dfa.c (struct dfa): Simplify by removing nmultibyte_prop; it should always be the same as talloc. All uses changed. --- src/dfa.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/dfa.c b/src/dfa.c index a3e8bd0..050a180 100644 --- a/src/dfa.c +++ b/src/dfa.c @@ -359,7 +359,6 @@ struct dfa multibyte_prop = 3 , 1 , 0 , 2 , 3 */ - size_t nmultibyte_prop; int *multibyte_prop; /* A table indexed by byte values that contains the corresponding wide @@ -1581,16 +1580,16 @@ static size_t depth; /* Current depth of a hypothetical stack static void addtok_mb (token t, int mbprop) { - if (MB_CUR_MAX > 1) + if (dfa->talloc == dfa->tindex) { - dfa->multibyte_prop = maybe_realloc (dfa->multibyte_prop, dfa->tindex, - &dfa->nmultibyte_prop, - sizeof *dfa->multibyte_prop); - dfa->multibyte_prop[dfa->tindex] = mbprop; + dfa->tokens = x2nrealloc (dfa->tokens, &dfa->talloc, + sizeof *dfa->tokens); + if (MB_CUR_MAX > 1) + dfa->multibyte_prop = xnrealloc (dfa->multibyte_prop, dfa->talloc, + sizeof *dfa->multibyte_prop); } - - dfa->tokens = maybe_realloc (dfa->tokens, dfa->tindex, &dfa->talloc, - sizeof *dfa->tokens); + if (MB_CUR_MAX > 1) + dfa->multibyte_prop[dfa->tindex] = mbprop; dfa->tokens[dfa->tindex++] = t; switch (t) -- 1.9.0