Since the mixer uses 'delete' to free memory, we should allocate it with 'new'.

I don't know if I got all cases, but I no longer get any Valgrind warnings at
the beginning of CoMI when using the original sound/music files.

svn-id: r30501
This commit is contained in:
Torbjörn Andersson 2008-01-15 20:30:48 +00:00
parent d0e5df5bfa
commit 5dc2caa307
4 changed files with 4 additions and 4 deletions

View File

@ -302,7 +302,7 @@ void IMuseDigital::callback() {
int tmpFeedSize = _sound->getDataFromRegion(track->soundDesc, track->curRegion, &tmpPtr, tmpOffset, tmpFeedSize12Bits);
curFeedSize = BundleCodecs::decode12BitsSample(tmpPtr, &tmpSndBufferPtr, tmpFeedSize);
free(tmpPtr);
delete[] tmpPtr;
} else if (bits == 16) {
curFeedSize = _sound->getDataFromRegion(track->soundDesc, track->curRegion, &tmpSndBufferPtr, track->regionOffset, feedSize);
if (channels == 1) {

View File

@ -281,7 +281,7 @@ int32 BundleMgr::decompressSampleByIndex(int32 index, int32 offset, int32 size,
lastBlock = _numCompItems - 1;
int32 blocksFinalSize = 0x2000 * (1 + lastBlock - firstBlock);
*compFinal = (byte *)malloc(blocksFinalSize);
*compFinal = new byte[blocksFinalSize];
assert(*compFinal);
finalSize = 0;

View File

@ -34,7 +34,7 @@ namespace BundleCodecs {
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);
byte *ptr = *dst = new byte[s_size];
assert(ptr);
uint32 tmp;

View File

@ -461,7 +461,7 @@ ImuseDigiSndMgr::SoundDesc *ImuseDigiSndMgr::openSound(int32 soundId, const char
sound->disk = _disk;
prepareSound(ptr, sound);
if ((soundType == IMUSE_BUNDLE) && !sound->compressed) {
free(ptr);
delete[] ptr;
}
return sound;
}