diff options
author | Chris Dyer <cdyer@cs.cmu.edu> | 2011-03-03 13:14:08 -0500 |
---|---|---|
committer | Chris Dyer <cdyer@cs.cmu.edu> | 2011-03-03 13:14:08 -0500 |
commit | f190b1fecf1f2ba891419a7cf9e4f9fb3a4c5b02 (patch) | |
tree | d0ae338849d744326034e205da71b00291cd3671 | |
parent | 5c1f2543319f52e8866647369db209e4e9320ab0 (diff) |
fix potential crash on long sentences
-rw-r--r-- | decoder/bottom_up_parser.cc | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/decoder/bottom_up_parser.cc b/decoder/bottom_up_parser.cc index aecf1cfa..e3751e23 100644 --- a/decoder/bottom_up_parser.cc +++ b/decoder/bottom_up_parser.cc @@ -219,8 +219,10 @@ void PassiveChart::ApplyUnaryRules(const int i, const int j) { } bool PassiveChart::Parse() { - forest_->nodes_.reserve(input_.size() * input_.size() * 2); - forest_->edges_.reserve(input_.size() * input_.size() * 1000); // TODO: reservation?? + size_t in_size_2 = input_.size() * input_.size(); + forest_->nodes_.reserve(in_size_2 * 2); + size_t res = min(2000000ul, in_size_2 * 1000); + forest_->edges_.reserve(res); goal_idx_ = -1; for (int gi = 0; gi < grammars_.size(); ++gi) act_chart_[gi]->SeedActiveChart(*grammars_[gi]); |