(svn r12783) -Codechange: do not statically allocate the 'temporary map3 array' in the oldloader.
authorrubidium
Sat, 19 Apr 2008 08:34:03 +0000
changeset 10251 b41d7d8c873b
parent 10250 e64ee7484b43
child 10252 8d87c2f342cb
(svn r12783) -Codechange: do not statically allocate the 'temporary map3 array' in the oldloader.
src/oldloader.cpp
--- a/src/oldloader.cpp	Sat Apr 19 08:21:55 2008 +0000
+++ b/src/oldloader.cpp	Sat Apr 19 08:34:03 2008 +0000
@@ -401,7 +401,7 @@
 extern char *_old_name_array;
 
 static byte   _old_vehicle_multiplier;
-static uint8  _old_map3[OLD_MAP_SIZE * 2];
+static uint8  *_old_map3;
 static bool   _new_ttdpatch_format;
 static uint32 _old_town_index;
 static uint16 _old_string_id;
@@ -1608,8 +1608,10 @@
 
 	DEBUG(oldloader, 3, "Reading main chunk...");
 	/* Load the biggest chunk */
+	_old_map3 = MallocT<byte>(OLD_MAP_SIZE * 2);
 	if (!LoadChunk(ls, NULL, main_chunk)) {
 		DEBUG(oldloader, 0, "Loading failed");
+		free(_old_map3);
 		return false;
 	}
 	DEBUG(oldloader, 3, "Done, converting game data...");
@@ -1676,6 +1678,8 @@
 	DEBUG(oldloader, 3, "Finished converting game data");
 	DEBUG(oldloader, 1, "TTD(Patch) savegame successfully converted");
 
+	free(_old_map3);
+
 	return true;
 }