Skip to content

Commit d8a91d3

Browse files
committed
Silence compiler warning about too large allocation size
git-svn-id: svn://tron.homeunix.org/simutrans/simutrans/trunk@11884 8aca7d54-2c30-db11-9de9-000461428c89
1 parent d47c5c9 commit d8a91d3

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

src/simutrans/world/simworld.cc

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1665,17 +1665,20 @@ void karte_t::enlarge_map(settings_t const* sets, sint8 const* const h_field)
16651665
{
16661666
const koord new_size(sets->get_size_x(), sets->get_size_y());
16671667

1668+
assert(new_size.x >= 0);
1669+
assert(new_size.y >= 0);
1670+
16681671
if( cached_grid_size.y>0 && cached_grid_size.y!=new_size.y ) {
16691672
// to keep the labels
16701673
grund_t::enlarge_map( new_size.x, new_size.y );
16711674
}
16721675

1673-
planquadrat_t *new_plan = new planquadrat_t[new_size.x*new_size.y];
1674-
sint8 *new_grid_hgts = new sint8[(new_size.x + 1) * (new_size.y + 1)];
1675-
sint8 *new_water_hgts = new sint8[new_size.x * new_size.y];
1676+
planquadrat_t *new_plan = new planquadrat_t[(uint32) new_size.x * (uint32) new_size.y];
1677+
sint8 *new_grid_hgts = new sint8 [(uint32)(new_size.x + 1) * (uint32)(new_size.y + 1)];
1678+
sint8 *new_water_hgts = new sint8 [(uint32) new_size.x * (uint32) new_size.y];
16761679

1677-
memset( new_grid_hgts, groundwater, sizeof(sint8) * (new_size.x + 1) * (new_size.y + 1) );
1678-
memset( new_water_hgts, groundwater, sizeof(sint8) * new_size.x * new_size.y );
1680+
memset( new_grid_hgts, groundwater, sizeof(sint8) * (new_size.x + 1) * (new_size.y + 1) );
1681+
memset( new_water_hgts, groundwater, sizeof(sint8) * new_size.x * new_size.y );
16791682

16801683
const koord old_size = get_size();
16811684
const bool new_world = old_size.x == 0 && old_size.y == 0;
@@ -2373,10 +2376,13 @@ DBG_MESSAGE( "karte_t::rotate90()", "called" );
23732376
s->release_factory_links();
23742377
}
23752378

2376-
//rotate plans in parallel posix thread ...
2377-
rotate90_new_plan = new planquadrat_t[cached_grid_size.y * cached_grid_size.x];
2378-
rotate90_new_water = new sint8[cached_grid_size.y * cached_grid_size.x];
2379+
assert(cached_grid_size.x >= 0);
2380+
assert(cached_grid_size.y >= 0);
23792381

2382+
rotate90_new_plan = new planquadrat_t[(uint32_t)cached_grid_size.y * (uint32_t)cached_grid_size.x];
2383+
rotate90_new_water = new sint8 [(uint32_t)cached_grid_size.y * (uint32_t)cached_grid_size.x];
2384+
2385+
//rotate plans in parallel posix thread ...
23802386
world_xy_loop(&karte_t::rotate90_plans, 0);
23812387

23822388
grund_t::finish_rotate90();

0 commit comments

Comments
 (0)