[Scummvm-cvs-logs] SF.net SVN: scummvm: [20733] scummvm/trunk/engines/scumm/imuse_digi

aquadran at users.sourceforge.net aquadran at users.sourceforge.net
Thu Feb 16 13:51:01 CET 2006


Revision: 20733
Author:   aquadran
Date:     2006-02-16 13:50:14 -0800 (Thu, 16 Feb 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm?rev=20733&view=rev

Log Message:
-----------
added more asserts into imuse digi code

Modified Paths:
--------------
    scummvm/trunk/engines/scumm/imuse_digi/dimuse.cpp
    scummvm/trunk/engines/scumm/imuse_digi/dimuse_bndmgr.cpp
    scummvm/trunk/engines/scumm/imuse_digi/dimuse_codecs.cpp
    scummvm/trunk/engines/scumm/imuse_digi/dimuse_sndmgr.cpp
Modified: scummvm/trunk/engines/scumm/imuse_digi/dimuse.cpp
===================================================================
--- scummvm/trunk/engines/scumm/imuse_digi/dimuse.cpp	2006-02-16 21:46:45 UTC (rev 20732)
+++ scummvm/trunk/engines/scumm/imuse_digi/dimuse.cpp	2006-02-16 21:50:14 UTC (rev 20733)
@@ -48,10 +48,12 @@
 	: _vm(scumm) {
 	_pause = false;
 	_sound = new ImuseDigiSndMgr(_vm);
+	assert(_sound);
 	_callbackFps = fps;
 	resetState();
 	for (int l = 0; l < MAX_DIGITAL_TRACKS + MAX_DIGITAL_FADETRACKS; l++) {
 		_track[l] = new Track;
+		assert(_track[l]);
 		_track[l]->trackId = l;
 		_track[l]->used = false;
 	}

Modified: scummvm/trunk/engines/scumm/imuse_digi/dimuse_bndmgr.cpp
===================================================================
--- scummvm/trunk/engines/scumm/imuse_digi/dimuse_bndmgr.cpp	2006-02-16 21:46:45 UTC (rev 20732)
+++ scummvm/trunk/engines/scumm/imuse_digi/dimuse_bndmgr.cpp	2006-02-16 21:50:14 UTC (rev 20733)
@@ -94,12 +94,14 @@
 
 		strcpy(_budleDirCache[freeSlot].fileName, filename);
 		_budleDirCache[freeSlot].numFiles = file.readUint32BE();
-		_budleDirCache[freeSlot].bundleTable = (AudioTable *) malloc(_budleDirCache[freeSlot].numFiles * sizeof(AudioTable));
+		_budleDirCache[freeSlot].bundleTable = (AudioTable *)malloc(_budleDirCache[freeSlot].numFiles * sizeof(AudioTable));
+		assert(_budleDirCache[freeSlot].bundleTable);
 
 		file.seek(offset, SEEK_SET);
 
 		_budleDirCache[freeSlot].indexTable =
 				(IndexNode *)calloc(_budleDirCache[freeSlot].numFiles, sizeof(IndexNode));
+		assert(_budleDirCache[freeSlot].indexTable);
 
 		for (int32 i = 0; i < _budleDirCache[freeSlot].numFiles; i++) {
 			char name[24], c;
@@ -222,6 +224,7 @@
 	}
 
 	_compTable = (CompTable *)malloc(sizeof(CompTable) * _numCompItems);
+	assert(_compTable);
 	int32 maxSize = 0;
 	for (int i = 0; i < _numCompItems; i++) {
 		_compTable[i].offset = _file.readUint32BE();
@@ -233,6 +236,7 @@
 	}
 	// CMI hack: one more byte at the end of input buffer
 	_compInput = (byte *)malloc(maxSize + 1);
+	assert(_compInput);
 
 	return true;
 }
@@ -272,6 +276,7 @@
 
 	int32 blocks_final_size = 0x2000 * (1 + last_block - first_block);
 	*comp_final = (byte *)malloc(blocks_final_size);
+	assert(*comp_final);
 	final_size = 0;
 
 	skip = (offset + header_size) % 0x2000;

Modified: scummvm/trunk/engines/scumm/imuse_digi/dimuse_codecs.cpp
===================================================================
--- scummvm/trunk/engines/scumm/imuse_digi/dimuse_codecs.cpp	2006-02-16 21:46:45 UTC (rev 20732)
+++ scummvm/trunk/engines/scumm/imuse_digi/dimuse_codecs.cpp	2006-02-16 21:50:14 UTC (rev 20733)
@@ -31,6 +31,7 @@
 	uint32 loop_size = size / 3;
 	uint32 s_size = loop_size * 4;
 	byte *ptr = *dst = (byte *)malloc(s_size);
+	assert(ptr);
 
 	uint32 tmp;
 	while (loop_size--) {
@@ -224,6 +225,7 @@
 			p[z] += p[z - 1];
 
 		t_table = (byte *)malloc(output_size);
+		assert(t_table);
 
 		src = comp_output;
 		length = (output_size << 3) / 12;
@@ -265,6 +267,7 @@
 			p[z] += p[z - 1];
 
 		t_table = (byte *)malloc(output_size);
+		assert(t_table);
 
 		src = comp_output;
 		length = (output_size << 3) / 12;
@@ -306,6 +309,7 @@
 			p[z] += p[z - 1];
 
 		t_table = (byte *)malloc(output_size);
+		assert(t_table);
 
 		src = comp_output;
 		length = (output_size << 3) / 12;
@@ -348,6 +352,7 @@
 			p[z] += p[z - 1];
 
 		t_table = (byte *)malloc(output_size);
+		assert(t_table);
 		memcpy(t_table, p, output_size);
 
 		offset1 = output_size / 3;
@@ -401,6 +406,7 @@
 			p[z] += p[z - 1];
 
 		t_table = (byte *)malloc(output_size);
+		assert(t_table);
 		memcpy(t_table, p, output_size);
 
 		offset1 = output_size / 3;
@@ -454,6 +460,7 @@
 			p[z] += p[z - 1];
 
 		t_table = (byte *)malloc(output_size);
+		assert(t_table);
 		memcpy(t_table, p, output_size);
 
 		offset1 = output_size / 3;

Modified: scummvm/trunk/engines/scumm/imuse_digi/dimuse_sndmgr.cpp
===================================================================
--- scummvm/trunk/engines/scumm/imuse_digi/dimuse_sndmgr.cpp	2006-02-16 21:46:45 UTC (rev 20732)
+++ scummvm/trunk/engines/scumm/imuse_digi/dimuse_sndmgr.cpp	2006-02-16 21:50:14 UTC (rev 20733)
@@ -42,6 +42,7 @@
 	_vm = scumm;
 	_disk = 0;
 	_cacheBundleDir = new BundleDirCache();
+	assert(_cacheBundleDir);
 	BundleCodecs::initializeImcTables();
 }
 
@@ -101,8 +102,11 @@
 	sound->numJumps = file->readUint32BE();
 	sound->numSyncs = file->readUint32BE();
 	sound->region = (_region *)malloc(sizeof(_region) * sound->numRegions);
+	assert(sound->region);
 	sound->jump = (_jump *)malloc(sizeof(_jump) * sound->numJumps);
+	assert(sound->jump);
 	sound->sync = (_sync *)malloc(sizeof(_sync) * sound->numSyncs);
+	assert(sound->sync);
 	for (l = 0; l < sound->numRegions; l++) {
 		sound->region[l].offset = file->readUint32BE();
 		sound->region[l].length = file->readUint32BE();
@@ -129,7 +133,9 @@
 		int16 code = READ_LE_UINT16(ptr + 24);
 
 		sound->region = (_region *)malloc(sizeof(_region) * 70);
+		assert(sound->region);
 		sound->jump = (_jump *)malloc(sizeof(_jump));
+		assert(sound->jump);
 		sound->resPtr = ptr;
 		sound->bits = 8;
 		sound->channels = 1;
@@ -197,8 +203,11 @@
 		sound->numSyncs = 0;
 		countElements(ptr, sound->numRegions, sound->numJumps, sound->numSyncs);
 		sound->region = (_region *)malloc(sizeof(_region) * sound->numRegions);
+		assert(sound->region);
 		sound->jump = (_jump *)malloc(sizeof(_jump) * sound->numJumps);
+		assert(sound->jump);
 		sound->sync = (_sync *)malloc(sizeof(_sync) * sound->numSyncs);
+		assert(sound->sync);
 
 		do {
 			tag = READ_BE_UINT32(ptr); ptr += 4;
@@ -263,6 +272,7 @@
 	bool result = false;
 
 	sound->bundle = new BundleMgr(_cacheBundleDir);
+	assert(sound->bundle);
 	if (_vm->_gameId == GID_CMI) {
 		if (_vm->_features & GF_DEMO) {
 			result = sound->bundle->open("music.bun", sound->compressed);
@@ -297,6 +307,7 @@
 	bool result = false;
 
 	sound->bundle = new BundleMgr(_cacheBundleDir);
+	assert(sound->bundle);
 	if (_vm->_gameId == GID_CMI) {
 		if (_vm->_features & GF_DEMO) {
 			result = sound->bundle->open("voice.bun", sound->compressed);
@@ -573,9 +584,11 @@
 		size = soundHandle->bundle->decompressSampleByCurIndex(start + offset, size, buf, header_size, header_outside);
 	} else if (soundHandle->resPtr) {
 		*buf = (byte *)malloc(size);
+		assert(*buf);
 		memcpy(*buf, soundHandle->resPtr + start + offset + header_size, size);
 	} else if ((soundHandle->bundle) && (soundHandle->compressed)) {
 		*buf = (byte *)malloc(size);
+		assert(*buf);
 		char fileName[24];
 		sprintf(fileName, "%s_reg%03d", soundHandle->name, region);
 		if (scumm_stricmp(fileName, soundHandle->lastFileName) != 0) {







More information about the Scummvm-git-logs mailing list