[Scummvm-cvs-logs] CVS: scummvm/scumm/imuse_digi dimuse_bndmgr.cpp,1.6,1.7

Max Horn fingolfin at users.sourceforge.net
Wed Jan 7 05:30:01 CET 2004


Update of /cvsroot/scummvm/scummvm/scumm/imuse_digi
In directory sc8-pr-cvs1:/tmp/cvs-serv9002

Modified Files:
	dimuse_bndmgr.cpp 
Log Message:
malloc/new are relatively slow operations; avoid doing them in tight loops, if possible

Index: dimuse_bndmgr.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/imuse_digi/dimuse_bndmgr.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- dimuse_bndmgr.cpp	7 Jan 2004 04:50:38 -0000	1.6
+++ dimuse_bndmgr.cpp	7 Jan 2004 13:29:12 -0000	1.7
@@ -204,11 +204,13 @@
 
 	int skip = offset - (first_block * 0x2000) + header_size;
 
+	// CMI hack: one more zero byte at the end of input buffer
+	comp_input = (byte *)malloc(0x2000);
+	comp_input[0x2000-1] = 0;
+
 	for (i = first_block; i <= last_block; i++) {
 		assert(size);
-		// CMI hack: one more zero byte at the end of input buffer
-		comp_input = (byte *)malloc(_compTable[i].size + 1);
-		comp_input[_compTable[i].size] = 0;
+		assert(0x2000 >= _compTable[i].size + 1);
 
 		byte *curBuf;
 		if (_lastBlock != i) {
@@ -236,9 +238,8 @@
 		final_size += output_size;
 		size -= output_size;
 		skip = 0;
-
-		free(comp_input);
 	}
+	free(comp_input);
 	free(comp_output);
 
 	return final_size;





More information about the Scummvm-git-logs mailing list