diff options
author | Matthew Hoops | 2011-07-02 19:44:04 -0400 |
---|---|---|
committer | Matthew Hoops | 2011-07-02 19:44:04 -0400 |
commit | 9dd8650872e4053c78df9609ec59d4b500a19692 (patch) | |
tree | f9811a976c4c785d11dba1489aeaaf5478b54717 /common | |
parent | 7c28d22ca01e3479532d06b5c4c8f3b9fe299ee4 (diff) | |
download | scummvm-rg350-9dd8650872e4053c78df9609ec59d4b500a19692.tar.gz scummvm-rg350-9dd8650872e4053c78df9609ec59d4b500a19692.tar.bz2 scummvm-rg350-9dd8650872e4053c78df9609ec59d4b500a19692.zip |
COMMON: Cleanup BitStream
Fix mismatched new[]/free and restored a missing statement
Diffstat (limited to 'common')
-rw-r--r-- | common/bitstream.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/common/bitstream.cpp b/common/bitstream.cpp index fb40957ef6..b41ad237e0 100644 --- a/common/bitstream.cpp +++ b/common/bitstream.cpp @@ -49,12 +49,14 @@ BitStreamBE::BitStreamBE(SeekableReadStream &stream, uint32 bitCount) : _value(0 // Read the number of bytes of the stream uint32 byteSize = bitCount / 8; - byte *data = new byte[byteSize]; + byte *data = (byte *)malloc(byteSize); if (stream.read(data, byteSize) != byteSize) { - delete[] data; + free(data); error("Bad BitStreamBE size"); } + + _stream = new MemoryReadStream(data, byteSize, DisposeAfterUse::YES); } BitStreamBE::BitStreamBE(const byte *data, uint32 bitCount) : _value(0), _inValue(0) { @@ -64,7 +66,7 @@ BitStreamBE::BitStreamBE(const byte *data, uint32 bitCount) : _value(0), _inValu // Copy the number of bytes from the data array uint32 byteSize = bitCount / 8; - byte *dataN = new byte[byteSize]; + byte *dataN = (byte *)malloc(byteSize); memcpy(dataN, data, byteSize); @@ -133,10 +135,10 @@ BitStream32LE::BitStream32LE(SeekableReadStream &stream, uint32 bitCount) : _val // Read the number of bytes of the stream uint32 byteSize = bitCount / 8; - byte *data = new byte[byteSize]; + byte *data = (byte *)malloc(byteSize); if (stream.read(data, byteSize) != byteSize) { - delete[] data; + free(data); error("Bad BitStream32LE size"); } @@ -150,7 +152,7 @@ BitStream32LE::BitStream32LE(const byte *data, uint32 bitCount) : _value(0), _in // Copy the number of bytes from the data array uint32 byteSize = bitCount / 8; - byte *dataN = new byte[byteSize]; + byte *dataN = (byte *)malloc(byteSize); memcpy(dataN, data, byteSize); |