diff options
author | Max Horn | 2004-01-07 13:29:12 +0000 |
---|---|---|
committer | Max Horn | 2004-01-07 13:29:12 +0000 |
commit | 2e1026f8fea74e413e85ea5f83ee8d9e681af811 (patch) | |
tree | 929742ada818dc8798db85c44e33f30a67d11f20 /scumm/imuse_digi | |
parent | a2fbba2e4e9a241464fc2b64de3d963e692fa2d6 (diff) | |
download | scummvm-rg350-2e1026f8fea74e413e85ea5f83ee8d9e681af811.tar.gz scummvm-rg350-2e1026f8fea74e413e85ea5f83ee8d9e681af811.tar.bz2 scummvm-rg350-2e1026f8fea74e413e85ea5f83ee8d9e681af811.zip |
malloc/new are relatively slow operations; avoid doing them in tight loops, if possible
svn-id: r12213
Diffstat (limited to 'scumm/imuse_digi')
-rw-r--r-- | scumm/imuse_digi/dimuse_bndmgr.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/scumm/imuse_digi/dimuse_bndmgr.cpp b/scumm/imuse_digi/dimuse_bndmgr.cpp index a763d78485..329311e73e 100644 --- a/scumm/imuse_digi/dimuse_bndmgr.cpp +++ b/scumm/imuse_digi/dimuse_bndmgr.cpp @@ -204,11 +204,13 @@ int32 BundleMgr::decompressSampleByIndex(int32 index, int32 offset, int32 size, 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 @@ int32 BundleMgr::decompressSampleByIndex(int32 index, int32 offset, int32 size, final_size += output_size; size -= output_size; skip = 0; - - free(comp_input); } + free(comp_input); free(comp_output); return final_size; |