diff options
author | Paweł Kołodziejski | 2006-02-16 21:50:14 +0000 |
---|---|---|
committer | Paweł Kołodziejski | 2006-02-16 21:50:14 +0000 |
commit | 8b76033dc3cd09ab8b717fe8e4e41fa2de1bcc19 (patch) | |
tree | 63b09b09e95e797602cfb17a991f7da1711472ab /engines/scumm | |
parent | fbefbfc160ddaaecffa192b2784726f5677e73f3 (diff) | |
download | scummvm-rg350-8b76033dc3cd09ab8b717fe8e4e41fa2de1bcc19.tar.gz scummvm-rg350-8b76033dc3cd09ab8b717fe8e4e41fa2de1bcc19.tar.bz2 scummvm-rg350-8b76033dc3cd09ab8b717fe8e4e41fa2de1bcc19.zip |
added more asserts into imuse digi code
svn-id: r20733
Diffstat (limited to 'engines/scumm')
-rw-r--r-- | engines/scumm/imuse_digi/dimuse.cpp | 2 | ||||
-rw-r--r-- | engines/scumm/imuse_digi/dimuse_bndmgr.cpp | 7 | ||||
-rw-r--r-- | engines/scumm/imuse_digi/dimuse_codecs.cpp | 7 | ||||
-rw-r--r-- | engines/scumm/imuse_digi/dimuse_sndmgr.cpp | 13 |
4 files changed, 28 insertions, 1 deletions
diff --git a/engines/scumm/imuse_digi/dimuse.cpp b/engines/scumm/imuse_digi/dimuse.cpp index c057cc8d85..b2c498a1c0 100644 --- a/engines/scumm/imuse_digi/dimuse.cpp +++ b/engines/scumm/imuse_digi/dimuse.cpp @@ -48,10 +48,12 @@ IMuseDigital::IMuseDigital(ScummEngine *scumm, int fps) : _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; } diff --git a/engines/scumm/imuse_digi/dimuse_bndmgr.cpp b/engines/scumm/imuse_digi/dimuse_bndmgr.cpp index d36d733ef2..5da2c17efe 100644 --- a/engines/scumm/imuse_digi/dimuse_bndmgr.cpp +++ b/engines/scumm/imuse_digi/dimuse_bndmgr.cpp @@ -94,12 +94,14 @@ int BundleDirCache::matchFile(const char *filename) { 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 @@ bool BundleMgr::loadCompTable(int32 index) { } _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 @@ bool BundleMgr::loadCompTable(int32 index) { } // 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 BundleMgr::decompressSampleByIndex(int32 index, int32 offset, int32 size, 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; diff --git a/engines/scumm/imuse_digi/dimuse_codecs.cpp b/engines/scumm/imuse_digi/dimuse_codecs.cpp index dccae928b0..116c78bf5c 100644 --- a/engines/scumm/imuse_digi/dimuse_codecs.cpp +++ b/engines/scumm/imuse_digi/dimuse_codecs.cpp @@ -31,6 +31,7 @@ uint32 decode12BitsSample(const byte *src, byte **dst, uint32 size) { 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 @@ int32 decompressCodec(int32 codec, byte *comp_input, byte *comp_output, int32 in 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 @@ int32 decompressCodec(int32 codec, byte *comp_input, byte *comp_output, int32 in 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 @@ int32 decompressCodec(int32 codec, byte *comp_input, byte *comp_output, int32 in 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 @@ int32 decompressCodec(int32 codec, byte *comp_input, byte *comp_output, int32 in 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 @@ int32 decompressCodec(int32 codec, byte *comp_input, byte *comp_output, int32 in 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 @@ int32 decompressCodec(int32 codec, byte *comp_input, byte *comp_output, int32 in p[z] += p[z - 1]; t_table = (byte *)malloc(output_size); + assert(t_table); memcpy(t_table, p, output_size); offset1 = output_size / 3; diff --git a/engines/scumm/imuse_digi/dimuse_sndmgr.cpp b/engines/scumm/imuse_digi/dimuse_sndmgr.cpp index 7d3d06f16e..6adef74ab7 100644 --- a/engines/scumm/imuse_digi/dimuse_sndmgr.cpp +++ b/engines/scumm/imuse_digi/dimuse_sndmgr.cpp @@ -42,6 +42,7 @@ ImuseDigiSndMgr::ImuseDigiSndMgr(ScummEngine *scumm) { _vm = scumm; _disk = 0; _cacheBundleDir = new BundleDirCache(); + assert(_cacheBundleDir); BundleCodecs::initializeImcTables(); } @@ -101,8 +102,11 @@ void ImuseDigiSndMgr::prepareSoundFromRMAP(Common::File *file, soundStruct *soun 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 @@ void ImuseDigiSndMgr::prepareSound(byte *ptr, soundStruct *sound) { 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 @@ void ImuseDigiSndMgr::prepareSound(byte *ptr, soundStruct *sound) { 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 ImuseDigiSndMgr::openMusicBundle(soundStruct *sound, int disk) { 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 ImuseDigiSndMgr::openVoiceBundle(soundStruct *sound, int disk) { 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 @@ int32 ImuseDigiSndMgr::getDataFromRegion(soundStruct *soundHandle, int region, b 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) { |