diff --git a/audio/decoders/wma.cpp b/audio/decoders/wma.cpp index 6f9fdf2aea9..c769827ca90 100644 --- a/audio/decoders/wma.cpp +++ b/audio/decoders/wma.cpp @@ -590,9 +590,8 @@ Common::SeekableReadStream *WMACodec::decodeSuperFrame(Common::SeekableReadStrea // PCM output data outputDataSize = frameCount * _channels * _frameLen; - outputData = new int16[outputDataSize]; + outputData = new int16[outputDataSize](); - memset(outputData, 0, outputDataSize * 2); // Number of bits data that completes the last superframe's overhang. int bitOffset = bits.getBits(_byteOffsetBits + 3); @@ -664,9 +663,8 @@ Common::SeekableReadStream *WMACodec::decodeSuperFrame(Common::SeekableReadStrea // PCM output data outputDataSize = _channels * _frameLen; - outputData = new int16[outputDataSize]; + outputData = new int16[outputDataSize](); - memset(outputData, 0, outputDataSize * 2); // Decode the frame if (!decodeFrame(bits, outputData)) { diff --git a/audio/mods/mod_xm_s3m.cpp b/audio/mods/mod_xm_s3m.cpp index e19983744d0..2a7bf677da8 100644 --- a/audio/mods/mod_xm_s3m.cpp +++ b/audio/mods/mod_xm_s3m.cpp @@ -1347,8 +1347,7 @@ void ModXmS3mStream::setSequencePos(int pos) { _playCount = new int8 *[_module.sequenceLen]; memset(_playCount, 0, _module.sequenceLen * sizeof(int8 *)); int len = initPlayCount(_playCount); - _playCount[0] = new int8[len]; - memset(_playCount[0], 0, len * sizeof(int8)); + _playCount[0] = new int8[len](); initPlayCount(_playCount); for (int idx = 0; idx < _module.numChannels; ++idx) { diff --git a/audio/mods/module_mod_xm_s3m.cpp b/audio/mods/module_mod_xm_s3m.cpp index 61c697343e0..08971d93930 100644 --- a/audio/mods/module_mod_xm_s3m.cpp +++ b/audio/mods/module_mod_xm_s3m.cpp @@ -218,8 +218,7 @@ bool ModuleModXmS3m::loadMod(Common::SeekableReadStream &st) { // load instruments numInstruments = 31; - instruments = new Instrument[numInstruments + 1]; - memset(instruments, 0, sizeof(Instrument) * (numInstruments + 1)); + instruments = new Instrument[numInstruments + 1](); instruments[0].numSamples = 1; instruments[0].samples = new Sample[1]; memset(&instruments[0].samples[0], 0, sizeof(Sample)); @@ -332,8 +331,7 @@ bool ModuleModXmS3m::loadMod(Common::SeekableReadStream &st) { */ int numNotes = patterns[i].numChannels * patterns[i].numRows; - patterns[i].notes = new Note[numNotes]; - memset(patterns[i].notes, 0, numNotes * sizeof(Note)); + patterns[i].notes = new Note[numNotes](); for (int idx = 0; idx < numNotes; ++idx) { byte first = st.readByte(); byte second = st.readByte(); @@ -451,8 +449,7 @@ bool ModuleModXmS3m::loadXm(Common::SeekableReadStream &st) { // load notes patterns[i].numChannels = numChannels; int numNotes = patterns[i].numRows * numChannels; - patterns[i].notes = new Note[numNotes]; - memset(patterns[i].notes, 0, numNotes * sizeof(Note)); + patterns[i].notes = new Note[numNotes](); if (patDataLength > 0) { for (int j = 0; j < numNotes; ++j) { @@ -484,10 +481,8 @@ bool ModuleModXmS3m::loadXm(Common::SeekableReadStream &st) { } // load instruments - instruments = new Instrument[numInstruments + 1]; - memset(instruments, 0, (numInstruments + 1) * sizeof(Instrument)); - instruments[0].samples = new Sample[1]; - memset(instruments[0].samples, 0, sizeof(Sample)); + instruments = new Instrument[numInstruments + 1](); + instruments[0].samples = new Sample[1](); for (int i = 1; i <= numInstruments; ++i) { st.seek(offset, SEEK_SET); offset += st.readUint32LE(); @@ -501,8 +496,7 @@ bool ModuleModXmS3m::loadXm(Common::SeekableReadStream &st) { // load sample number int nSamples = st.readUint16LE(); ins.numSamples = nSamples > 0 ? nSamples : 1; - ins.samples = new Sample[ins.numSamples]; - memset(ins.samples, 0, ins.numSamples * sizeof(Sample)); + ins.samples = new Sample[ins.numSamples](); st.readUint32LE(); // skip 4 byte // load instrument informations @@ -656,16 +650,13 @@ bool ModuleModXmS3m::loadS3m(Common::SeekableReadStream &st) { int moduleDataIndex = st.pos(); // load instruments - instruments = new Instrument[numInstruments + 1]; - memset(instruments, 0, sizeof(Instrument) * (numInstruments + 1)); + instruments = new Instrument[numInstruments + 1](); instruments[0].numSamples = 1; - instruments[0].samples = new Sample[1]; - memset(instruments[0].samples, 0, sizeof(Sample)); + instruments[0].samples = new Sample[1](); for (int i = 1; i <= numInstruments; ++i) { Instrument &instrum = instruments[i]; instrum.numSamples = 1; - instrum.samples = new Sample[1]; - memset(instrum.samples, 0, sizeof(Sample)); + instrum.samples = new Sample[1](); Sample &sample = instrum.samples[0]; // get instrument offset @@ -725,8 +716,7 @@ bool ModuleModXmS3m::loadS3m(Common::SeekableReadStream &st) { } // load patterns - patterns = new Pattern[numPatterns]; - memset(patterns, 0, numPatterns * sizeof(Pattern)); + patterns = new Pattern[numPatterns](); for (int i = 0; i < numPatterns; ++i) { patterns[i].numChannels = numChannels; patterns[i].numRows = 64; @@ -737,8 +727,7 @@ bool ModuleModXmS3m::loadS3m(Common::SeekableReadStream &st) { st.seek(patOffset, SEEK_SET); // load notes - patterns[i].notes = new Note[numChannels * 64]; - memset(patterns[i].notes, 0, numChannels * 64 * sizeof(Note)); + patterns[i].notes = new Note[numChannels * 64](); int row = 0; while (row < 64) { byte token = st.readByte(); @@ -794,8 +783,7 @@ bool ModuleModXmS3m::loadS3m(Common::SeekableReadStream &st) { } // load default panning - defaultPanning = new byte[numChannels]; - memset(defaultPanning, 0, numChannels); + defaultPanning = new byte[numChannels](); for (int chan = 0; chan < 32; ++chan) { if (channelMap[chan] >= 0) { byte panning = 7; @@ -837,8 +825,7 @@ bool ModuleModXmS3m::loadAmf(Common::SeekableReadStream &st) { st.read(sequence, 256); // Always 256 bytes in the file. // Read sample headers.. - instruments = new Instrument[numInstruments + 1]; - memset(instruments, 0, sizeof(Instrument) * (numInstruments + 1)); + instruments = new Instrument[numInstruments + 1](); instruments[0].numSamples = 1; instruments[0].samples = new Sample[1]; memset(&instruments[0].samples[0], 0, sizeof(Sample)); @@ -874,16 +861,14 @@ bool ModuleModXmS3m::loadAmf(Common::SeekableReadStream &st) { st.skip((64 - numInstruments) * 37); // 37 == sample header len // load patterns - patterns = new Pattern[numPatterns]; - memset(patterns, 0, numPatterns * sizeof(Pattern)); + patterns = new Pattern[numPatterns](); for (int i = 0; i < numPatterns; ++i) { // Always 8 channels, 64 rows. patterns[i].numChannels = 8; patterns[i].numRows = 64; // load notes - patterns[i].notes = new Note[8 * 64]; - memset(patterns[i].notes, 0, 8 * 64 * sizeof(Note)); + patterns[i].notes = new Note[8 * 64](); for (int row = 0; row < 64; row++) { for (int channel = 0; channel < 8; channel++) { Note &n = patterns[i].notes[row * 8 + channel]; diff --git a/audio/softsynth/fmtowns_pc98/sega_audio.cpp b/audio/softsynth/fmtowns_pc98/sega_audio.cpp index 798a2b84a9d..0965e27982b 100644 --- a/audio/softsynth/fmtowns_pc98/sega_audio.cpp +++ b/audio/softsynth/fmtowns_pc98/sega_audio.cpp @@ -190,8 +190,7 @@ bool SegaAudioInterfaceInternal::init() { if (!TownsPC98_FmSynth::init()) return false; - _pcmBanks = new int8[0x10000]; - memset(_pcmBanks, 0, 0x10000); + _pcmBanks = new int8[0x10000](); _pcmChan = new SegaPCMChannel*[8]; _psgDev = new SegaPSG(7670454 / 72, 16); _pcmDev = new PCMDevice_Base(33300, 16, 8); diff --git a/audio/softsynth/fmtowns_pc98/towns_pc98_fmsynth.cpp b/audio/softsynth/fmtowns_pc98/towns_pc98_fmsynth.cpp index 8be4ae90e0b..0109e0d868f 100644 --- a/audio/softsynth/fmtowns_pc98/towns_pc98_fmsynth.cpp +++ b/audio/softsynth/fmtowns_pc98/towns_pc98_fmsynth.cpp @@ -1139,8 +1139,7 @@ int TownsPC98_FmSynth::readBuffer(int16 *buffer, const int numSamples) { } delete[] _renderBuffer; _renderBufferSize = requiredSize; - _renderBuffer = new int32[_renderBufferSize]; - memset(_renderBuffer, 0, sizeof(int32) * _renderBufferSize); + _renderBuffer = new int32[_renderBufferSize](); } int outSamplesLeft = numSamples >> 1; @@ -1320,8 +1319,7 @@ void TownsPC98_FmSynth::generateTables() { } delete[] _oprRateshift; - _oprRateshift = new uint8[130]; - memset(_oprRateshift, 0, 130); + _oprRateshift = new uint8[130](); dst = (uint8 *)_oprRateshift + 32; for (int i = 11; i; i--) { memset(dst, i, 4); @@ -1334,8 +1332,7 @@ void TownsPC98_FmSynth::generateTables() { _oprFrq[i] = (uint32)i << (11 - _rateScale); delete[] _oprAttackDecay; - _oprAttackDecay = new uint8[152]; - memset(_oprAttackDecay, 0, 152); + _oprAttackDecay = new uint8[152](); for (int i = 0; i < 36; i++) WRITE_BE_UINT32(_oprAttackDecay + (i << 2), _adtStat[i]); diff --git a/backends/platform/android3d/texture.cpp b/backends/platform/android3d/texture.cpp index b206c29c30b..72628746fcc 100644 --- a/backends/platform/android3d/texture.cpp +++ b/backends/platform/android3d/texture.cpp @@ -349,10 +349,8 @@ GLESFakePaletteTexture::GLESFakePaletteTexture(GLenum glFormat, GLenum glType, _palettePixelFormat = pixelFormat; _fake_format = Graphics::PixelFormat::createFormatCLUT8(); - _palette = new uint16[256]; + _palette = new uint16[256](); assert(_palette); - - memset(_palette, 0, 256 * 2); } GLESFakePaletteTexture::~GLESFakePaletteTexture() { diff --git a/backends/platform/psp/tests.cpp b/backends/platform/psp/tests.cpp index 450a48e5632..a9e0ce2c0e6 100644 --- a/backends/platform/psp/tests.cpp +++ b/backends/platform/psp/tests.cpp @@ -618,8 +618,7 @@ bool PspUnitTests::testFileSystem() { } // read the contents - char *readBuffer = new char[BufSize + 4]; - memset(readBuffer, 0, (BufSize + 4)); + char *readBuffer = new char[BufSize + 4](); index = readBuffer; while (rdStream->read(index, 100) == 100) { index += 100; @@ -682,8 +681,7 @@ bool PspUnitTests::testFileSystem() { return false; } - char *readPhrase = new char[phraseLen + 2]; - memset(readPhrase, 0, phraseLen + 2); + char *readPhrase = new char[phraseLen + 2](); if ((ret = rdStream->read(readPhrase, phraseLen) != phraseLen)) { PSP_ERROR("read error on phrase. Got %d instead of %d\n", ret, phraseLen); diff --git a/common/str-enc.cpp b/common/str-enc.cpp index f1edf1aeac4..892f67fadeb 100644 --- a/common/str-enc.cpp +++ b/common/str-enc.cpp @@ -320,8 +320,7 @@ void String::encodeWindows932(const U32String &src) { loadCJKTables(); if (!reverseTable && windows932ConversionTable) { - uint16 *rt = new uint16[0x10000]; - memset(rt, 0, sizeof(rt[0]) * 0x10000); + uint16 *rt = new uint16[0x10000](); for (uint highidx = 0; highidx < 47; highidx++) { uint8 high = 0; if (highidx < 4) @@ -390,8 +389,7 @@ void String::encodeWindows949(const U32String &src) { loadCJKTables(); if (!reverseTable && windows949ConversionTable) { - uint16 *rt = new uint16[0x10000]; - memset(rt, 0, sizeof(rt[0]) * 0x10000); + uint16 *rt = new uint16[0x10000](); for (uint lowidx = 0; lowidx < 0xb2; lowidx++) { uint8 low = 0; @@ -480,8 +478,7 @@ void String::encodeWindows950(const U32String &src, bool transliterate) { loadCJKTables(); if (!reverseTable && windows950ConversionTable) { - uint16 *rt = new uint16[0x10000]; - memset(rt, 0, sizeof(rt[0]) * 0x10000); + uint16 *rt = new uint16[0x10000](); for (uint lowidx = 0; lowidx < 157; lowidx++) { uint8 low = 0; diff --git a/common/winexe.cpp b/common/winexe.cpp index 191f8620f06..a0366b1abdb 100644 --- a/common/winexe.cpp +++ b/common/winexe.cpp @@ -123,9 +123,8 @@ bool WinResources::loadFromCompressedEXE(const String &fileName) { file.readByte(); // file name character change uint32 unpackedLength = file.readUint32LE(); - byte *window = new byte[0x1000]; + byte *window = new byte[0x1000](); int pos = 0x1000 - 16; - memset(window, 0x20, 0x1000); // Initialize to all spaces byte *unpackedData = (byte *)malloc(unpackedLength); assert(unpackedData); diff --git a/graphics/fonts/macfont.cpp b/graphics/fonts/macfont.cpp index 742ae693ba5..dcc3c5a8e2f 100644 --- a/graphics/fonts/macfont.cpp +++ b/graphics/fonts/macfont.cpp @@ -576,8 +576,7 @@ MacFONTFont *MacFONTFont::scaleFont(const MacFONTFont *src, int newSize, int sla data._rowWords = newBitmapWidth; uint bitImageSize = data._rowWords * data._fRectHeight; - data._bitImage = new byte[bitImageSize]; - memset(data._bitImage, 0, bitImageSize * sizeof(byte)); + data._bitImage = new byte[bitImageSize](); int dstPitch = data._rowWords; diff --git a/graphics/scalerplugin.cpp b/graphics/scalerplugin.cpp index b2904de60da..7301ffec38e 100644 --- a/graphics/scalerplugin.cpp +++ b/graphics/scalerplugin.cpp @@ -83,8 +83,7 @@ void SourceScaler::setSource(const byte *src, uint pitch, int width, int height, // Give _oldSrc same pitch int size = (height + padding * 2) * pitch; - _oldSrc = new byte[size]; - memset(_oldSrc, 0, size); + _oldSrc = new byte[size](); _bufferedOutput.create(_width * _factor, _height * _factor, _format); } diff --git a/image/codecs/codec.cpp b/image/codecs/codec.cpp index 47480c5a909..9ecedc9b8b0 100644 --- a/image/codecs/codec.cpp +++ b/image/codecs/codec.cpp @@ -75,8 +75,7 @@ inline uint16 makeQuickTimeDitherColor(byte r, byte g, byte b) { } // End of anonymous namespace byte *Codec::createQuickTimeDitherTable(const byte *palette, uint colorCount) { - byte *buf = new byte[0x10000]; - memset(buf, 0, 0x10000); + byte *buf = new byte[0x10000](); Common::List checkQueue; diff --git a/image/codecs/indeo3.cpp b/image/codecs/indeo3.cpp index 2b681c98ced..639831ece39 100644 --- a/image/codecs/indeo3.cpp +++ b/image/codecs/indeo3.cpp @@ -155,8 +155,7 @@ void Indeo3Decoder::allocFrames() { _iv_frame[0].the_buf_size = bufsize; _iv_frame[1].the_buf_size = 0; - _iv_frame[0].the_buf = new byte[bufsize]; - memset(_iv_frame[0].the_buf, 0, bufsize); + _iv_frame[0].the_buf = new byte[bufsize](); _iv_frame[1].the_buf = 0; uint32 offs = 0; diff --git a/image/codecs/xan.cpp b/image/codecs/xan.cpp index d46c3b91975..432d0c8aa1e 100644 --- a/image/codecs/xan.cpp +++ b/image/codecs/xan.cpp @@ -59,16 +59,11 @@ XanDecoder::XanDecoder(int width, int height, int bitsPerPixel) : Codec(), if (width % 2) error("XanDecoder: width must be even, not %d", width); _surface.create(_width, _height, getPixelFormat()); - _scratchbuf = new uint8[_width * _height + SCRATCH_SPARE]; - _lumabuf = new uint8[_width * _height]; - _ybuf = new uint8[_width * _height]; - _ubuf = new uint8[_width * _height / 2]; - _vbuf = new uint8[_width * _height / 2]; - memset(_scratchbuf, 0, _width * _height + SCRATCH_SPARE); - memset(_lumabuf, 0, _width * _height); - memset(_ybuf, 0, _width * _height); - memset(_ubuf, 127, _width * _height / 2); - memset(_vbuf, 127, _width * _height / 2); + _scratchbuf = new uint8[_width * _height + SCRATCH_SPARE](); + _lumabuf = new uint8[_width * _height](); + _ybuf = new uint8[_width * _height](); + _ubuf = new uint8[_width * _height / 2](); + _vbuf = new uint8[_width * _height / 2](); } XanDecoder::~XanDecoder() { diff --git a/image/pict.cpp b/image/pict.cpp index e7a65b80e59..47f4892725f 100644 --- a/image/pict.cpp +++ b/image/pict.cpp @@ -344,9 +344,7 @@ void PICTDecoder::unpackBitsRect(Common::SeekableReadStream &stream, bool withPa // Ensure we have enough space in the buffer to hold an entire line's worth of pixels uint32 lineSize = MAX(width * bytesPerPixel + (8 * 2 / packBitsData.pixMap.pixelSize), packBitsData.pixMap.rowBytes); - byte *buffer = new byte[lineSize * height]; - - memset(buffer, 0, lineSize * height); + byte *buffer = new byte[lineSize * height](); // Read in amount of data per row for (uint16 i = 0; i < packBitsData.pixMap.bounds.height(); i++) { diff --git a/video/avi_decoder.cpp b/video/avi_decoder.cpp index ae86821a229..54bcfef1048 100644 --- a/video/avi_decoder.cpp +++ b/video/avi_decoder.cpp @@ -335,8 +335,7 @@ void AVIDecoder::handleStreamHeader(uint32 size) { byte *initialPalette = 0; if (bmInfo.bitCount == 8) { - initialPalette = new byte[256 * 3]; - memset(initialPalette, 0, 256 * 3); + initialPalette = new byte[256 * 3](); byte *palette = initialPalette; for (uint32 i = 0; i < bmInfo.clrUsed; i++) { diff --git a/video/bink_decoder.cpp b/video/bink_decoder.cpp index 56f58ed8855..b420e61c7ee 100644 --- a/video/bink_decoder.cpp +++ b/video/bink_decoder.cpp @@ -293,23 +293,17 @@ BinkDecoder::BinkVideoTrack::BinkVideoTrack(uint32 width, uint32 height, const G _uvBlockHeight = (height + 15) >> 4; // The planes are sized according to the number of blocks - _curPlanes[0] = new byte[_yBlockWidth * 8 * _yBlockHeight * 8]; // Y - _curPlanes[1] = new byte[_uvBlockWidth * 8 * _uvBlockHeight * 8]; // U, 1/4 resolution - _curPlanes[2] = new byte[_uvBlockWidth * 8 * _uvBlockHeight * 8]; // V, 1/4 resolution + _curPlanes[0] = new byte[_yBlockWidth * 8 * _yBlockHeight * 8](); // Y + _curPlanes[1] = new byte[_uvBlockWidth * 8 * _uvBlockHeight * 8](); // U, 1/4 resolution + _curPlanes[2] = new byte[_uvBlockWidth * 8 * _uvBlockHeight * 8](); // V, 1/4 resolution _curPlanes[3] = new byte[_yBlockWidth * 8 * _yBlockHeight * 8]; // A - _oldPlanes[0] = new byte[_yBlockWidth * 8 * _yBlockHeight * 8]; // Y - _oldPlanes[1] = new byte[_uvBlockWidth * 8 * _uvBlockHeight * 8]; // U, 1/4 resolution - _oldPlanes[2] = new byte[_uvBlockWidth * 8 * _uvBlockHeight * 8]; // V, 1/4 resolution + _oldPlanes[0] = new byte[_yBlockWidth * 8 * _yBlockHeight * 8](); // Y + _oldPlanes[1] = new byte[_uvBlockWidth * 8 * _uvBlockHeight * 8](); // U, 1/4 resolution + _oldPlanes[2] = new byte[_uvBlockWidth * 8 * _uvBlockHeight * 8](); // V, 1/4 resolution _oldPlanes[3] = new byte[_yBlockWidth * 8 * _yBlockHeight * 8]; // A // Initialize the video with solid green - memset(_curPlanes[0], 0, _yBlockWidth * 8 * _yBlockHeight * 8); - memset(_curPlanes[1], 0, _uvBlockWidth * 8 * _uvBlockHeight * 8); - memset(_curPlanes[2], 0, _uvBlockWidth * 8 * _uvBlockHeight * 8); memset(_curPlanes[3], 255, _yBlockWidth * 8 * _yBlockHeight * 8); - memset(_oldPlanes[0], 0, _yBlockWidth * 8 * _yBlockHeight * 8); - memset(_oldPlanes[1], 0, _uvBlockWidth * 8 * _uvBlockHeight * 8); - memset(_oldPlanes[2], 0, _uvBlockWidth * 8 * _uvBlockHeight * 8); memset(_oldPlanes[3], 255, _yBlockWidth * 8 * _yBlockHeight * 8); initBundles(); diff --git a/video/coktel_decoder.cpp b/video/coktel_decoder.cpp index 9862c7fe5ab..0906202f41a 100644 --- a/video/coktel_decoder.cpp +++ b/video/coktel_decoder.cpp @@ -742,9 +742,7 @@ bool PreIMDDecoder::loadStream(Common::SeekableReadStream *stream) { _frameCount = _stream->readUint16LE(); _videoBufferSize = _width * _height; - _videoBuffer = new byte[_videoBufferSize]; - - memset(_videoBuffer, 0, _videoBufferSize); + _videoBuffer = new byte[_videoBufferSize](); return true; } @@ -1141,8 +1139,7 @@ bool IMDDecoder::assessVideoProperties() { } for (int i = 0; i < 2; i++) { - _videoBuffer[i] = new byte[_videoBufferSize]; - memset(_videoBuffer[i], 0, _videoBufferSize); + _videoBuffer[i] = new byte[_videoBufferSize](); } return true; @@ -1958,8 +1955,7 @@ bool VMDDecoder::assessVideoProperties() { } for (int i = 0; i < 3; i++) { - _videoBuffer[i] = new byte[_videoBufferSize]; - memset(_videoBuffer[i], 0, _videoBufferSize); + _videoBuffer[i] = new byte[_videoBufferSize](); _8bppSurface[i].init(_width * _bytesPerPixel, _height, _width * _bytesPerPixel, _videoBuffer[i], Graphics::PixelFormat::createFormatCLUT8()); diff --git a/video/dxa_decoder.cpp b/video/dxa_decoder.cpp index 97d13b05f34..129782e4177 100644 --- a/video/dxa_decoder.cpp +++ b/video/dxa_decoder.cpp @@ -107,15 +107,12 @@ DXADecoder::DXAVideoTrack::DXAVideoTrack(Common::SeekableReadStream *stream) { _frameSize = _width * _height; _decompBufferSize = _frameSize; - _frameBuffer1 = new byte[_frameSize]; - memset(_frameBuffer1, 0, _frameSize); - _frameBuffer2 = new byte[_frameSize]; - memset(_frameBuffer2, 0, _frameSize); + _frameBuffer1 = new byte[_frameSize](); + _frameBuffer2 = new byte[_frameSize](); _scaledBuffer = 0; if (_scaleMode != S_NONE) { - _scaledBuffer = new byte[_frameSize]; - memset(_scaledBuffer, 0, _frameSize); + _scaledBuffer = new byte[_frameSize](); } #ifdef DXA_EXPERIMENT_MAXD @@ -185,8 +182,7 @@ void DXADecoder::DXAVideoTrack::decodeZlib(byte *data, int size, int totalSize) void DXADecoder::DXAVideoTrack::decode12(int size) { #ifdef USE_ZLIB if (!_decompBuffer) { - _decompBuffer = new byte[_decompBufferSize]; - memset(_decompBuffer, 0, _decompBufferSize); + _decompBuffer = new byte[_decompBufferSize](); } /* decompress the input data */ @@ -286,8 +282,7 @@ void DXADecoder::DXAVideoTrack::decode13(int size) { uint8 *codeBuf, *dataBuf, *motBuf, *maskBuf; if (!_decompBuffer) { - _decompBuffer = new byte[_decompBufferSize]; - memset(_decompBuffer, 0, _decompBufferSize); + _decompBuffer = new byte[_decompBufferSize](); } /* decompress the input data */ @@ -482,8 +477,7 @@ const Graphics::Surface *DXADecoder::DXAVideoTrack::decodeNextFrame() { if (!_inBuffer || _inBufferSize < size) { delete[] _inBuffer; - _inBuffer = new byte[size]; - memset(_inBuffer, 0, size); + _inBuffer = new byte[size](); _inBufferSize = size; } diff --git a/video/flic_decoder.cpp b/video/flic_decoder.cpp index 24af024fcad..b7dcf6e21cd 100644 --- a/video/flic_decoder.cpp +++ b/video/flic_decoder.cpp @@ -91,8 +91,7 @@ FlicDecoder::FlicVideoTrack::FlicVideoTrack(Common::SeekableReadStream *stream, _surface = new Graphics::Surface(); _surface->create(width, height, Graphics::PixelFormat::createFormatCLUT8()); - _palette = new byte[3 * 256]; - memset(_palette, 0, 3 * 256); + _palette = new byte[3 * 256](); _dirtyPalette = false; _curFrame = -1; diff --git a/video/hnm_decoder.cpp b/video/hnm_decoder.cpp index 6747674c220..2584bbcf6cf 100644 --- a/video/hnm_decoder.cpp +++ b/video/hnm_decoder.cpp @@ -184,12 +184,9 @@ HNMDecoder::HNM4VideoTrack::HNM4VideoTrack(uint32 width, uint32 height, uint32 f error("Invalid frameSize: expected %d, got %d", width * height, frameSize); } - _frameBufferF = new byte[frameSize]; - memset(_frameBufferF, 0, frameSize); - _frameBufferC = new byte[frameSize]; - memset(_frameBufferC, 0, frameSize); - _frameBufferP = new byte[frameSize]; - memset(_frameBufferP, 0, frameSize); + _frameBufferF = new byte[frameSize](); + _frameBufferC = new byte[frameSize](); + _frameBufferP = new byte[frameSize](); // We will use _frameBufferF/C/P as the surface pixels, just init there with nullptr to avoid unintended usage of surface const Graphics::PixelFormat &f = Graphics::PixelFormat::createFormatCLUT8(); diff --git a/video/qt_decoder.cpp b/video/qt_decoder.cpp index 1644dc9f5c7..833873314d0 100644 --- a/video/qt_decoder.cpp +++ b/video/qt_decoder.cpp @@ -152,8 +152,7 @@ Common::QuickTimeParser::SampleDesc *QuickTimeDecoder::readSampleDesc(Common::Qu // if the depth is 2, 4, or 8 bpp, file is palettized if (colorDepth == 2 || colorDepth == 4 || colorDepth == 8) { // Initialize the palette - entry->_palette = new byte[256 * 3]; - memset(entry->_palette, 0, 256 * 3); + entry->_palette = new byte[256 * 3](); if (colorGreyscale) { debug(0, "Greyscale palette");