Changeset - r8040:e05f3ded186d
[Not reviewed]
master
0 10 0
glx - 17 years ago 2007-12-08 15:47:23
glx@openttd.org
(svn r11600) -Cleanup: remove extra out-of-memory checks, since it's now done in *allocT functions.
10 files changed with 4 insertions and 26 deletions:
0 comments (0 inline, 0 general)
src/group_gui.cpp
Show inline comments
 
@@ -43,9 +43,6 @@ static void BuildGroupList(grouplist_d* 
 
	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* 
 

	
 
	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];
src/industry_gui.cpp
Show inline comments
 
@@ -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) {
src/map.cpp
Show inline comments
 
@@ -52,14 +52,13 @@ void AllocateMap(uint size_x, uint size_
 
	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);
 
}
 

	
 

	
src/network/network_gui.cpp
Show inline comments
 
@@ -167,7 +167,6 @@ static void BuildNetworkGameList(network
 
	/* 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) {
src/newgrf.cpp
Show inline comments
 
@@ -5421,7 +5421,6 @@ static void DecodeSpecialSprite(uint num
 
		/* 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. */
src/oldpool.cpp
Show inline comments
 
@@ -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));
src/signs_gui.cpp
Show inline comments
 
@@ -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;
src/spritecache.cpp
Show inline comments
 
@@ -53,10 +53,6 @@ static SpriteCache *AllocateSpriteCache(
 

	
 
		_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;
src/station_gui.cpp
Show inline comments
 
@@ -228,7 +228,6 @@ static void BuildStationsList(plstations
 

	
 
	/* 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
 

	
 
	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];
src/town_gui.cpp
Show inline comments
 
@@ -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;
 

	
0 comments (0 inline, 0 general)