From 4ffb06ee501d9806542c34a9aac8e6406416d35b Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Thu, 3 Mar 2011 13:14:08 -0500 Subject: fix potential crash on long sentences --- decoder/bottom_up_parser.cc | 6 ++++-- 1 file 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]); -- cgit v1.2.3