From 4ccdb5ec4e12b427f1a2069174db8c38bf65fd40 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sun, 10 Jan 2010 14:55:13 -0600 Subject: try to avoid crashes due to reallocation better --- crawl-ref/source/dungeon.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'crawl-ref/source') diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc index 7baa51eb3f..bc66d16e9b 100644 --- a/crawl-ref/source/dungeon.cc +++ b/crawl-ref/source/dungeon.cc @@ -7841,7 +7841,7 @@ static void _add_plant_clumps() } /* make sure the iterator stays valid */ - to_place.reserve((2 * i + 1) * (2 * i + 1)); + std::vector more_to_place; for (std::vector::const_iterator it = to_place.begin(); it != to_place.end(); ++it) @@ -7854,10 +7854,11 @@ static void _add_plant_clumps() if (abs(rad->x - it->x) <= 1 && abs(rad->y - it->y) <= 1) { if (one_chance_in(12)) { - to_place.push_back(*rad); + more_to_place.push_back(*rad); } } } + to_place.insert(to_place.end(), more_to_place.begin(), more_to_place.end()); } } -- cgit v1.2.3-54-g00ecf