From a9fa4dcd5dc1bb7b7aff5454ce9b9bb7e4166fc4 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Tue, 5 Jul 2011 11:27:10 +0200 Subject: dfa: x2nrealloc starting from a NULL pointer works * src/dfa.c (parse_bracket_exp): Do not MALLOC mbcset parts the first time they are encountered. Initialize chars_al correctly. --- src/dfa.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/dfa.c b/src/dfa.c index c7ba8db8..52050e09 100644 --- a/src/dfa.c +++ b/src/dfa.c @@ -798,7 +798,7 @@ parse_bracket_exp (void) int chars_al, range_sts_al, range_ends_al, ch_classes_al, equivs_al, coll_elems_al; - chars_al = 1; + chars_al = 0; range_sts_al = range_ends_al = 0; ch_classes_al = equivs_al = coll_elems_al = 0; if (MB_CUR_MAX > 1) @@ -881,8 +881,6 @@ parse_bracket_exp (void) /* Store the character class as wctype_t. */ wctype_t wt = wctype (class); - if (ch_classes_al == 0) - MALLOC(work_mbc->ch_classes, ++ch_classes_al); REALLOC_IF_NECESSARY(work_mbc->ch_classes, ch_classes_al, work_mbc->nch_classes + 1); @@ -903,8 +901,6 @@ parse_bracket_exp (void) if (c1 == '=') /* build equivalent class. */ { - if (equivs_al == 0) - MALLOC(work_mbc->equivs, ++equivs_al); REALLOC_IF_NECESSARY(work_mbc->equivs, equivs_al, work_mbc->nequivs + 1); @@ -914,8 +910,6 @@ parse_bracket_exp (void) if (c1 == '.') /* build collating element. */ { - if (coll_elems_al == 0) - MALLOC(work_mbc->coll_elems, ++coll_elems_al); REALLOC_IF_NECESSARY(work_mbc->coll_elems, coll_elems_al, work_mbc->ncoll_elems + 1); @@ -962,11 +956,6 @@ parse_bracket_exp (void) { /* When case folding map a range, say [m-z] (or even [M-z]) to the pair of ranges, [m-z] [M-Z]. */ - if (range_sts_al == 0) - { - MALLOC(work_mbc->range_sts, ++range_sts_al); - MALLOC(work_mbc->range_ends, ++range_ends_al); - } REALLOC_IF_NECESSARY(work_mbc->range_sts, range_sts_al, work_mbc->nranges + 1); REALLOC_IF_NECESSARY(work_mbc->range_ends, -- cgit v1.2.1