mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-02-06 22:37:22 +00:00
(svn r11600) -Cleanup: remove extra out-of-memory checks, since it's now done in *allocT functions.
This commit is contained in:
parent
2256d9d378
commit
b47bce651e
@ -43,9 +43,6 @@ static void BuildGroupList(grouplist_d* gl, PlayerID owner, VehicleType vehicle_
|
||||
if (!(gl->l.flags & VL_REBUILD)) return;
|
||||
|
||||
list = MallocT<const Group*>(GetGroupArraySize());
|
||||
if (GetGroupArraySize() != 0 && list == NULL) {
|
||||
error("Could not allocate memory for the group-sorting-list");
|
||||
}
|
||||
|
||||
FOR_ALL_GROUPS(g) {
|
||||
if (g->owner == owner && g->vehicle_type == vehicle_type) list[n++] = g;
|
||||
@ -53,9 +50,6 @@ static void BuildGroupList(grouplist_d* gl, PlayerID owner, VehicleType vehicle_
|
||||
|
||||
free((void*)gl->sort_list);
|
||||
gl->sort_list = MallocT<const Group *>(n);
|
||||
if (n != 0 && gl->sort_list == NULL) {
|
||||
error("Could not allocate memory for the group-sorting-list");
|
||||
}
|
||||
gl->l.list_length = n;
|
||||
|
||||
for (uint i = 0; i < n; ++i) gl->sort_list[i] = list[i];
|
||||
|
@ -752,7 +752,6 @@ static void MakeSortedIndustryList()
|
||||
|
||||
/* Create array for sorting */
|
||||
_industry_sort = ReallocT(_industry_sort, GetMaxIndustryIndex() + 1);
|
||||
if (_industry_sort == NULL) error("Could not allocate memory for the industry-sorting-list");
|
||||
|
||||
/* Don't attempt a sort if there are no industries */
|
||||
if (GetNumIndustries() != 0) {
|
||||
|
@ -52,14 +52,13 @@ void AllocateMap(uint size_x, uint size_y)
|
||||
free(_m);
|
||||
free(_me);
|
||||
|
||||
_m = CallocT<Tile>(_map_size);
|
||||
_me = CallocT<TileExtended>(_map_size);
|
||||
|
||||
/* XXX @todo handle memory shortage more gracefully
|
||||
* CallocT does the out-of-memory check
|
||||
* Maybe some attemps could be made to try with smaller maps down to 64x64
|
||||
* Maybe check for available memory before doing the calls, after all, we know how big
|
||||
* the map is */
|
||||
if ((_m == NULL) || (_me == NULL)) error("Failed to allocate memory for the map");
|
||||
_m = CallocT<Tile>(_map_size);
|
||||
_me = CallocT<TileExtended>(_map_size);
|
||||
}
|
||||
|
||||
|
||||
|
@ -167,7 +167,6 @@ static void BuildNetworkGameList(network_ql_d *nqld)
|
||||
/* Create temporary array of games to use for listing */
|
||||
free(nqld->sort_list);
|
||||
nqld->sort_list = MallocT<NetworkGameList*>(n);
|
||||
if (nqld->sort_list == NULL) error("Could not allocate memory for the network-game-sorting-list");
|
||||
nqld->l.list_length = n;
|
||||
|
||||
for (n = 0, ngl_temp = _network_game_list; ngl_temp != NULL; ngl_temp = ngl_temp->next) {
|
||||
|
@ -5421,7 +5421,6 @@ static void DecodeSpecialSprite(uint num, GrfLoadingStage stage)
|
||||
/* No preloaded sprite to work with; allocate and read the
|
||||
* pseudo sprite content. */
|
||||
buf = MallocT<byte>(num);
|
||||
if (buf == NULL) error("DecodeSpecialSprite: Could not allocate memory");
|
||||
FioReadBlock(buf, num);
|
||||
} else {
|
||||
/* Use the preloaded sprite data. */
|
||||
|
@ -55,12 +55,9 @@ bool OldMemoryPoolBase::AddBlockToPool()
|
||||
|
||||
/* Increase the poolsize */
|
||||
this->blocks = ReallocT(this->blocks, this->current_blocks + 1);
|
||||
if (this->blocks == NULL) error("Pool: (%s) could not allocate memory for blocks", this->name);
|
||||
|
||||
/* Allocate memory to the new block item */
|
||||
this->blocks[this->current_blocks] = MallocT<byte>(this->item_size * (1 << this->block_size_bits));
|
||||
if (this->blocks[this->current_blocks] == NULL)
|
||||
error("Pool: (%s) could not allocate memory for blocks", this->name);
|
||||
|
||||
/* Clean the content of the new block */
|
||||
memset(this->blocks[this->current_blocks], 0, this->item_size * (1 << this->block_size_bits));
|
||||
|
@ -47,7 +47,6 @@ static void GlobalSortSignList()
|
||||
|
||||
/* Create array for sorting */
|
||||
_sign_sort = ReallocT(_sign_sort, GetMaxSignIndex() + 1);
|
||||
if (_sign_sort == NULL) error("Could not allocate memory for the sign-sorting-list");
|
||||
|
||||
FOR_ALL_SIGNS(si) _sign_sort[n++] = si;
|
||||
_num_sign_sort = n;
|
||||
|
@ -53,10 +53,6 @@ static SpriteCache *AllocateSpriteCache(uint index)
|
||||
|
||||
_spritecache = ReallocT(_spritecache, items);
|
||||
|
||||
if (_spritecache == NULL) {
|
||||
error("Unable to allocate sprite cache of %d items (%d bytes)", items, items * sizeof(*_spritecache));
|
||||
}
|
||||
|
||||
/* Reset the new items and update the count */
|
||||
memset(_spritecache + _spritecache_items, 0, (items - _spritecache_items) * sizeof(*_spritecache));
|
||||
_spritecache_items = items;
|
||||
@ -411,8 +407,7 @@ static void DeleteEntryFromSpriteCache()
|
||||
|
||||
/* Display an error message and die, in case we found no sprite at all.
|
||||
* This shouldn't really happen, unless all sprites are locked. */
|
||||
if (best == (uint)-1)
|
||||
error("Out of sprite memory");
|
||||
if (best == (uint)-1) error("Out of sprite memory");
|
||||
|
||||
/* Mark the block as free (the block must be in use) */
|
||||
s = (MemBlock*)GetSpriteCache(best)->ptr - 1;
|
||||
|
@ -228,7 +228,6 @@ static void BuildStationsList(plstations_d* sl, PlayerID owner, byte facilities,
|
||||
|
||||
/* Create array for sorting */
|
||||
const Station** station_sort = MallocT<const Station*>(GetMaxStationIndex() + 1);
|
||||
if (station_sort == NULL) error("Could not allocate memory for the station-sorting-list");
|
||||
|
||||
DEBUG(misc, 3, "Building station list for player %d", owner);
|
||||
|
||||
@ -255,7 +254,6 @@ static void BuildStationsList(plstations_d* sl, PlayerID owner, byte facilities,
|
||||
|
||||
free((void*)sl->sort_list);
|
||||
sl->sort_list = MallocT<const Station*>(n);
|
||||
if (n != 0 && sl->sort_list == NULL) error("Could not allocate memory for the station-sorting-list");
|
||||
sl->list_length = n;
|
||||
|
||||
for (uint i = 0; i < n; ++i) sl->sort_list[i] = station_sort[i];
|
||||
|
@ -449,7 +449,6 @@ static void MakeSortedTownList()
|
||||
|
||||
/* Create array for sorting */
|
||||
_town_sort = ReallocT(_town_sort, GetMaxTownIndex() + 1);
|
||||
if (_town_sort == NULL) error("Could not allocate memory for the town-sorting-list");
|
||||
|
||||
FOR_ALL_TOWNS(t) _town_sort[n++] = t;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user