[Scummvm-cvs-logs] CVS: scummvm/scumm bundle.cpp,1.29,1.30 bundle.h,1.13,1.14 sound.cpp,1.93,1.94

Pawel Kolodziejski aquadran at users.sourceforge.net
Thu Mar 6 23:50:05 CET 2003


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

Modified Files:
	bundle.cpp bundle.h sound.cpp 
Log Message:
changed voice buffer allocation to needed size

Index: bundle.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/bundle.cpp,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- bundle.cpp	6 Mar 2003 21:45:53 -0000	1.29
+++ bundle.cpp	7 Mar 2003 07:49:10 -0000	1.30
@@ -238,7 +238,7 @@
 	return true;
 }
 
-int32 Bundle::decompressVoiceSampleByIndex(int32 index, byte *comp_final) {
+int32 Bundle::decompressVoiceSampleByIndex(int32 index, byte **comp_final) {
 	int32 i, tag, num, final_size, output_size;
 	byte *comp_input, *comp_output;
 
@@ -273,6 +273,8 @@
 
 	comp_output = (byte *)malloc(0x2000);
 
+	*comp_final = (byte *)malloc(0x2000 * num);
+
 	for (i = 0; i < num; i++) {
 		comp_input = (byte *)malloc(_compVoiceTable[i].size);
 
@@ -281,7 +283,7 @@
 
 		output_size = decompressCodec(_compVoiceTable[i].codec, comp_input, comp_output, _compVoiceTable[i].size);
 		assert(output_size <= 0x2000);
-		memcpy(comp_final + final_size, comp_output, output_size);
+		memcpy(*comp_final + final_size, comp_output, output_size);
 		final_size += output_size;
 
 		free(comp_input);
@@ -339,7 +341,7 @@
 	return final_size;
 }
 
-int32 Bundle::decompressVoiceSampleByName(char *name, byte *comp_final) {
+int32 Bundle::decompressVoiceSampleByName(char *name, byte **comp_final) {
 	int32 final_size = 0, i;
 
 	if (_voiceFile.isOpen() == false) {

Index: bundle.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/bundle.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- bundle.h	6 Mar 2003 21:45:53 -0000	1.13
+++ bundle.h	7 Mar 2003 07:49:10 -0000	1.14
@@ -63,8 +63,8 @@
 	void initializeImcTables();
 	bool openVoiceFile(const char *filename, const char *directory);
 	bool openMusicFile(const char *filename, const char *directory);
-	int32 decompressVoiceSampleByName(char *name, byte *comp_final);
-	int32 decompressVoiceSampleByIndex(int32 index, byte *comp_final);
+	int32 decompressVoiceSampleByName(char *name, byte **comp_final);
+	int32 decompressVoiceSampleByIndex(int32 index, byte **comp_final);
 	int32 decompressMusicSampleByName(char *name, int32 number, byte *comp_final);
 	int32 decompressMusicSampleByIndex(int32 index, int32 number, byte *comp_final);
 	int32 getNumberOfMusicSamplesByIndex(int32 index);

Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/sound.cpp,v
retrieving revision 1.93
retrieving revision 1.94
diff -u -d -r1.93 -r1.94
--- sound.cpp	7 Mar 2003 06:41:43 -0000	1.93
+++ sound.cpp	7 Mar 2003 07:49:10 -0000	1.94
@@ -1194,21 +1194,18 @@
 		strcpy(name, sound);
 		if (_scumm->_maxRooms != 6) // CMI demo does not have .IMX for voice but does for music...
 			strcat(name, ".IMX");
-		ptr = (byte *)malloc(1000000);
-		output_size = _scumm->_bundle->decompressVoiceSampleByName(name, ptr);
+		output_size = _scumm->_bundle->decompressVoiceSampleByName(name, &ptr);
 		if (output_size == 0) {
 			free(ptr);
 			return -1;
 		}
 	} else {
-		ptr = (byte *)malloc(1000000);
-		output_size = _scumm->_bundle->decompressVoiceSampleByName(sound, ptr);
+		output_size = _scumm->_bundle->decompressVoiceSampleByName(sound, &ptr);
 		if (output_size == 0) {
 			free(ptr);
 			return -1;
 		}
 	}
-	assert(output_size <= 1000000);
 	orig_ptr = ptr;
 
 	tag = READ_BE_UINT32(ptr); ptr += 4;





More information about the Scummvm-git-logs mailing list