diff options
author | David Turner | 2011-01-30 16:50:55 +0000 |
---|---|---|
committer | David Turner | 2011-01-30 16:50:55 +0000 |
commit | ec885e5665b662f5c531d790e80fd064b3c4c428 (patch) | |
tree | a2b583203d5946190ac31a69e4c5f54a16ad07a9 /engines/scumm/smush/channel.cpp | |
parent | b644c6d466621edc532ba9edb0bed5fbf09fe724 (diff) | |
download | scummvm-rg350-ec885e5665b662f5c531d790e80fd064b3c4c428.tar.gz scummvm-rg350-ec885e5665b662f5c531d790e80fd064b3c4c428.tar.bz2 scummvm-rg350-ec885e5665b662f5c531d790e80fd064b3c4c428.zip |
SCUMM: Fix Valgrind mismatched delete errors in SMUSH channel base class.
This was due to the SMUSH channel base class using new/delete to manage buffer, but the imuse_channel and saud_channel classes which subclass and override this using malloc/free.
The more C++ solution of moving all to new/delete was tried, but the buffer is passed into a MemoryReadStream and free()'d there, so all classes have been moved to malloc/free instead.
This is not a critical problem as the buffers are byte primitive type anyway.
svn-id: r55660
Diffstat (limited to 'engines/scumm/smush/channel.cpp')
-rw-r--r-- | engines/scumm/smush/channel.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/engines/scumm/smush/channel.cpp b/engines/scumm/smush/channel.cpp index ccf67764e3..4389890994 100644 --- a/engines/scumm/smush/channel.cpp +++ b/engines/scumm/smush/channel.cpp @@ -41,8 +41,8 @@ SmushChannel::SmushChannel(int32 track) : } SmushChannel::~SmushChannel() { - delete[] _tbuffer; - delete[] _sbuffer; + free(_tbuffer); + free(_sbuffer); } void SmushChannel::processBuffer() { @@ -60,7 +60,7 @@ void SmushChannel::processBuffer() { _sbuffer = _tbuffer; if (offset < _tbufferSize) { int new_size = _tbufferSize - offset; - _tbuffer = new byte[new_size]; + _tbuffer = (byte *)malloc(new_size); if (!_tbuffer) error("smush channel failed to allocate memory"); memcpy(_tbuffer, _sbuffer + offset, new_size); @@ -70,7 +70,7 @@ void SmushChannel::processBuffer() { _tbufferSize = 0; } if (_sbufferSize == 0) { - delete[] _sbuffer; + free(_sbuffer); _sbuffer = 0; } } else { @@ -86,23 +86,23 @@ void SmushChannel::processBuffer() { if (_inData) { _sbufferSize = _tbufferSize - offset; assert(_sbufferSize); - _sbuffer = new byte[_sbufferSize]; + _sbuffer = (byte *)malloc(_sbufferSize); if (!_sbuffer) error("smush channel failed to allocate memory"); memcpy(_sbuffer, _tbuffer + offset, _sbufferSize); - delete[] _tbuffer; + free(_tbuffer); _tbuffer = 0; _tbufferSize = 0; } else { if (offset) { byte *old = _tbuffer; int32 new_size = _tbufferSize - offset; - _tbuffer = new byte[new_size]; + _tbuffer = (byte *)malloc(new_size); if (!_tbuffer) error("smush channel failed to allocate memory"); memcpy(_tbuffer, old + offset, new_size); _tbufferSize = new_size; - delete[] old; + free(old); } } } |