summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2007-12-08 15:47:23 +0000
committerglx <glx@openttd.org>2007-12-08 15:47:23 +0000
commitb47bce651e64ddeab722f599c0a682281b626c45 (patch)
treea45a623dcb65481ea9d84f6b9645584f075b7849 /src
parent2256d9d378365850ba247e7e02631cf458a4fca2 (diff)
downloadopenttd-b47bce651e64ddeab722f599c0a682281b626c45.tar.xz
(svn r11600) -Cleanup: remove extra out-of-memory checks, since it's now done in *allocT functions.
Diffstat (limited to 'src')
-rw-r--r--src/group_gui.cpp6
-rw-r--r--src/industry_gui.cpp1
-rw-r--r--src/map.cpp7
-rw-r--r--src/network/network_gui.cpp1
-rw-r--r--src/newgrf.cpp1
-rw-r--r--src/oldpool.cpp3
-rw-r--r--src/signs_gui.cpp1
-rw-r--r--src/spritecache.cpp7
-rw-r--r--src/station_gui.cpp2
-rw-r--r--src/town_gui.cpp1
10 files changed, 4 insertions, 26 deletions
diff --git a/src/group_gui.cpp b/src/group_gui.cpp
index e4e0361b1..ce4742a92 100644
--- a/src/group_gui.cpp
+++ b/src/group_gui.cpp
@@ -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];
diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp
index 0b1383d5c..ef7df6bff 100644
--- a/src/industry_gui.cpp
+++ b/src/industry_gui.cpp
@@ -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) {
diff --git a/src/map.cpp b/src/map.cpp
index 4136740c0..a54760652 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -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);
}
diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp
index eb9c04e4b..1391030b2 100644
--- a/src/network/network_gui.cpp
+++ b/src/network/network_gui.cpp
@@ -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) {
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index 34b13b12b..a24d9aba0 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -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. */
diff --git a/src/oldpool.cpp b/src/oldpool.cpp
index df4731777..3d8326828 100644
--- a/src/oldpool.cpp
+++ b/src/oldpool.cpp
@@ -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));
diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp
index b0d7877fe..0397ce49f 100644
--- a/src/signs_gui.cpp
+++ b/src/signs_gui.cpp
@@ -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;
diff --git a/src/spritecache.cpp b/src/spritecache.cpp
index 90abb0526..fef1d536d 100644
--- a/src/spritecache.cpp
+++ b/src/spritecache.cpp
@@ -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;
diff --git a/src/station_gui.cpp b/src/station_gui.cpp
index 3d512ef3e..17a2e27a6 100644
--- a/src/station_gui.cpp
+++ b/src/station_gui.cpp
@@ -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];
diff --git a/src/town_gui.cpp b/src/town_gui.cpp
index ccc723e41..a9bae18a4 100644
--- a/src/town_gui.cpp
+++ b/src/town_gui.cpp
@@ -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;