[Scummvm-cvs-logs] SF.net SVN: scummvm:[40372] scummvm/trunk/engines/sci/engine/seg_manager. cpp

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Fri May 8 11:52:51 CEST 2009


Revision: 40372
          http://scummvm.svn.sourceforge.net/scummvm/?rev=40372&view=rev
Author:   fingolfin
Date:     2009-05-08 09:52:51 +0000 (Fri, 08 May 2009)

Log Message:
-----------
SCI: Added workaround for Common::Array<T>::resize() not zero-initing newly allocated memory if T is a scaler type, pointer, POD type. At least on OS X

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/seg_manager.cpp

Modified: scummvm/trunk/engines/sci/engine/seg_manager.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/seg_manager.cpp	2009-05-07 20:56:33 UTC (rev 40371)
+++ scummvm/trunk/engines/sci/engine/seg_manager.cpp	2009-05-08 09:52:51 UTC (rev 40372)
@@ -84,6 +84,8 @@
 	reserved_id--; // reserved_id runs in the reversed direction to make sure no one will use it.
 
 	_heap.resize(DEFAULT_SCRIPTS);
+	for (uint i = 0; i < _heap.size(); ++i)
+		_heap[i] = 0;
 
 	Clones_seg_id = 0;
 	Lists_seg_id = 0;
@@ -346,11 +348,14 @@
 	}
 
 	if (segid >= (int)_heap.size()) {
-		if (segid >= (int)_heap.size() * 2) {
+		const int oldSize = _heap.size();
+		if (segid >= oldSize * 2) {
 			sciprintf("SegManager: hash_map error or others??");
 			return NULL;
 		}
-		_heap.resize(_heap.size() * 2);
+		_heap.resize(oldSize * 2);
+		for (int i = oldSize; i < oldSize * 2; ++i)
+			_heap[i] = 0;
 	}
 
 	mem->_segmgrId = hash_id;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list