diff --git a/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h b/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h index ac9addd564..d3cf8a9b2c 100644 --- a/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h +++ b/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h @@ -1092,7 +1092,7 @@ private: } else { - allocatedData.malloc ((size_t) numChannels + 1, sizeof (Type*)); + allocatedData.malloc (numChannels + 1, sizeof (Type*)); channels = reinterpret_cast (allocatedData.get()); } diff --git a/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp b/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp index 6c8816f623..0bd25d589a 100644 --- a/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp +++ b/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp @@ -1139,8 +1139,8 @@ public: const int range = random.nextBool() ? 500 : 10; const int num = random.nextInt (range) + 1; - HeapBlock buffer1 ((size_t) num + 16), buffer2 ((size_t) num + 16); - HeapBlock buffer3 ((size_t) num + 16); + HeapBlock buffer1 (num + 16), buffer2 (num + 16); + HeapBlock buffer3 (num + 16); #if JUCE_ARM ValueType* const data1 = buffer1; diff --git a/modules/juce_audio_basics/effects/juce_Reverb.h b/modules/juce_audio_basics/effects/juce_Reverb.h index 02b95b3c31..9fa37b1232 100644 --- a/modules/juce_audio_basics/effects/juce_Reverb.h +++ b/modules/juce_audio_basics/effects/juce_Reverb.h @@ -229,7 +229,7 @@ private: if (size != bufferSize) { bufferIndex = 0; - buffer.malloc ((size_t) size); + buffer.malloc (size); bufferSize = size; } @@ -274,7 +274,7 @@ private: if (size != bufferSize) { bufferIndex = 0; - buffer.malloc ((size_t) size); + buffer.malloc (size); bufferSize = size; } diff --git a/modules/juce_audio_basics/midi/juce_MidiMessage.cpp b/modules/juce_audio_basics/midi/juce_MidiMessage.cpp index 761c578dc6..4ec9f61164 100644 --- a/modules/juce_audio_basics/midi/juce_MidiMessage.cpp +++ b/modules/juce_audio_basics/midi/juce_MidiMessage.cpp @@ -638,7 +638,7 @@ bool MidiMessage::isSysEx() const noexcept MidiMessage MidiMessage::createSysExMessage (const void* sysexData, const int dataSize) { - HeapBlock m ((size_t) dataSize + 2); + HeapBlock m (dataSize + 2); m[0] = 0xf0; memcpy (m + 1, sysexData, (size_t) dataSize); diff --git a/modules/juce_audio_basics/sources/juce_ResamplingAudioSource.cpp b/modules/juce_audio_basics/sources/juce_ResamplingAudioSource.cpp index 67ff49ccd4..c8c339ce4d 100644 --- a/modules/juce_audio_basics/sources/juce_ResamplingAudioSource.cpp +++ b/modules/juce_audio_basics/sources/juce_ResamplingAudioSource.cpp @@ -52,14 +52,14 @@ void ResamplingAudioSource::prepareToPlay (int samplesPerBlockExpected, double s { const SpinLock::ScopedLockType sl (ratioLock); - const int scaledBlockSize = roundToInt (samplesPerBlockExpected * ratio); + auto scaledBlockSize = roundToInt (samplesPerBlockExpected * ratio); input->prepareToPlay (scaledBlockSize, sampleRate * ratio); buffer.setSize (numChannels, scaledBlockSize + 32); - filterStates.calloc ((size_t) numChannels); - srcBuffers.calloc ((size_t) numChannels); - destBuffers.calloc ((size_t) numChannels); + filterStates.calloc (numChannels); + srcBuffers.calloc (numChannels); + destBuffers.calloc (numChannels); createLowPass (ratio); flushBuffers(); diff --git a/modules/juce_audio_devices/native/juce_linux_Midi.cpp b/modules/juce_audio_devices/native/juce_linux_Midi.cpp index ef4dfade87..4e0ab2a033 100644 --- a/modules/juce_audio_devices/native/juce_linux_Midi.cpp +++ b/modules/juce_audio_devices/native/juce_linux_Midi.cpp @@ -316,8 +316,8 @@ private: if (snd_midi_event_new (maxEventSize, &midiParser) >= 0) { - const int numPfds = snd_seq_poll_descriptors_count (seqHandle, POLLIN); - HeapBlock pfd ((size_t) numPfds); + auto numPfds = snd_seq_poll_descriptors_count (seqHandle, POLLIN); + HeapBlock pfd (numPfds); snd_seq_poll_descriptors (seqHandle, pfd, (unsigned int) numPfds, POLLIN); HeapBlock buffer (maxEventSize); diff --git a/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp b/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp index 0bd8f3fbcb..a3c3f069ce 100644 --- a/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp +++ b/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp @@ -190,11 +190,11 @@ public: void allocateTempBuffers() { - const int tempBufSize = bufferSize + 4; - audioBuffer.calloc ((size_t) ((numInputChans + numOutputChans) * tempBufSize)); + auto tempBufSize = bufferSize + 4; + audioBuffer.calloc ((numInputChans + numOutputChans) * tempBufSize); - tempInputBuffers.calloc ((size_t) numInputChans + 2); - tempOutputBuffers.calloc ((size_t) numOutputChans + 2); + tempInputBuffers.calloc (numInputChans + 2); + tempOutputBuffers.calloc (numOutputChans + 2); int count = 0; for (int i = 0; i < numInputChans; ++i) tempInputBuffers[i] = audioBuffer + count++ * tempBufSize; diff --git a/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp index 05c3c44eac..8f92d26c04 100644 --- a/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp @@ -440,7 +440,7 @@ public: HeapBlock channels; HeapBlock temp; - const int bitsToShift = 32 - (int) bitsPerSample; + auto bitsToShift = 32 - (int) bitsPerSample; if (bitsToShift > 0) { @@ -484,9 +484,9 @@ public: void writeMetaData (const FlacNamespace::FLAC__StreamMetadata* metadata) { using namespace FlacNamespace; - const FLAC__StreamMetadata_StreamInfo& info = metadata->data.stream_info; + auto& info = metadata->data.stream_info; - unsigned char buffer [FLAC__STREAM_METADATA_STREAMINFO_LENGTH]; + unsigned char buffer[FLAC__STREAM_METADATA_STREAMINFO_LENGTH]; const unsigned int channelsMinus1 = info.channels - 1; const unsigned int bitsMinus1 = info.bits_per_sample - 1; diff --git a/modules/juce_audio_formats/format/juce_AudioFormatReader.cpp b/modules/juce_audio_formats/format/juce_AudioFormatReader.cpp index fe5404aa16..3d5e898294 100644 --- a/modules/juce_audio_formats/format/juce_AudioFormatReader.cpp +++ b/modules/juce_audio_formats/format/juce_AudioFormatReader.cpp @@ -168,7 +168,7 @@ void AudioFormatReader::read (AudioSampleBuffer* buffer, } else { - HeapBlock chans ((size_t) numTargetChannels + 1); + HeapBlock chans (numTargetChannels + 1); readChannels (*this, chans, buffer, startSample, numSamples, readerStartSample, numTargetChannels); } diff --git a/modules/juce_audio_utils/gui/juce_AudioThumbnail.cpp b/modules/juce_audio_utils/gui/juce_AudioThumbnail.cpp index 1e3ea0eea6..4f50058acd 100644 --- a/modules/juce_audio_utils/gui/juce_AudioThumbnail.cpp +++ b/modules/juce_audio_utils/gui/juce_AudioThumbnail.cpp @@ -89,14 +89,12 @@ class AudioThumbnail::LevelDataSource : public TimeSliceClient { public: LevelDataSource (AudioThumbnail& thumb, AudioFormatReader* newReader, int64 hash) - : lengthInSamples (0), numSamplesFinished (0), sampleRate (0), numChannels (0), - hashCode (hash), owner (thumb), reader (newReader), lastReaderUseTime (0) + : hashCode (hash), owner (thumb), reader (newReader) { } LevelDataSource (AudioThumbnail& thumb, InputSource* src) - : lengthInSamples (0), numSamplesFinished (0), sampleRate (0), numChannels (0), - hashCode (src->hashCode()), owner (thumb), source (src), lastReaderUseTime (0) + : hashCode (src->hashCode()), owner (thumb), source (src) { } @@ -179,7 +177,6 @@ public: { const ScopedLock sl (readerLock); - createReader(); if (reader != nullptr) @@ -207,17 +204,17 @@ public: return (int) (originalSample / owner.samplesPerThumbSample); } - int64 lengthInSamples, numSamplesFinished; - double sampleRate; - unsigned int numChannels; - int64 hashCode; + int64 lengthInSamples = 0, numSamplesFinished = 0; + double sampleRate = 0; + unsigned int numChannels = 0; + int64 hashCode = 0; private: AudioThumbnail& owner; ScopedPointer source; ScopedPointer reader; CriticalSection readerLock; - uint32 lastReaderUseTime; + uint32 lastReaderUseTime = 0; void createReader() { @@ -232,23 +229,23 @@ private: if (! isFullyLoaded()) { - const int numToDo = (int) jmin (256 * (int64) owner.samplesPerThumbSample, lengthInSamples - numSamplesFinished); + auto numToDo = (int) jmin (256 * (int64) owner.samplesPerThumbSample, lengthInSamples - numSamplesFinished); if (numToDo > 0) { - int64 startSample = numSamplesFinished; + auto startSample = numSamplesFinished; - const int firstThumbIndex = sampleToThumbSample (startSample); - const int lastThumbIndex = sampleToThumbSample (startSample + numToDo); - const int numThumbSamps = lastThumbIndex - firstThumbIndex; + auto firstThumbIndex = sampleToThumbSample (startSample); + auto lastThumbIndex = sampleToThumbSample (startSample + numToDo); + auto numThumbSamps = lastThumbIndex - firstThumbIndex; - HeapBlock levelData ((size_t) numThumbSamps * numChannels); + HeapBlock levelData ((unsigned int) numThumbSamps * numChannels); HeapBlock levels (numChannels); for (int i = 0; i < (int) numChannels; ++i) levels[i] = levelData + i * numThumbSamps; - HeapBlock > levelsRead (numChannels); + HeapBlock> levelsRead (numChannels); for (int i = 0; i < numThumbSamps; ++i) { @@ -283,7 +280,7 @@ public: ensureSize (numThumbSamples); } - inline MinMaxValue* getData (const int thumbSampleIndex) noexcept + inline MinMaxValue* getData (int thumbSampleIndex) noexcept { jassert (thumbSampleIndex < data.size()); return data.getRawDataPointer() + thumbSampleIndex; @@ -305,7 +302,7 @@ public: while (startSample <= endSample) { - const MinMaxValue& v = data.getReference (startSample); + auto& v = data.getReference (startSample); if (v.getMinValue() < mn) mn = v.getMinValue(); if (v.getMaxValue() > mx) mx = v.getMaxValue(); @@ -323,14 +320,14 @@ public: result.set (1, 0); } - void write (const MinMaxValue* const values, const int startIndex, const int numValues) + void write (const MinMaxValue* values, int startIndex, int numValues) { resetPeak(); if (startIndex + numValues > data.size()) ensureSize (startIndex + numValues); - MinMaxValue* const dest = getData (startIndex); + auto* dest = getData (startIndex); for (int i = 0; i < numValues; ++i) dest[i] = values[i]; @@ -345,9 +342,10 @@ public: { if (peakLevel < 0) { - for (int i = 0; i < data.size(); ++i) + for (auto& s : data) { - const int peak = data[i].getPeak(); + auto peak = s.getPeak(); + if (peak > peakLevel) peakLevel = peak; } @@ -360,9 +358,10 @@ private: Array data; int peakLevel; - void ensureSize (const int thumbSamples) + void ensureSize (int thumbSamples) { - const int extraNeeded = thumbSamples - data.size(); + auto extraNeeded = thumbSamples - data.size(); + if (extraNeeded > 0) data.insertMultiple (-1, MinMaxValue(), extraNeeded); } @@ -372,12 +371,7 @@ private: class AudioThumbnail::CachedWindow { public: - CachedWindow() - : cachedStart (0), cachedTimePerPixel (0), - numChannelsCached (0), numSamplesCached (0), - cacheNeedsRefilling (true) - { - } + CachedWindow() {} void invalidate() { @@ -394,28 +388,28 @@ public: numChans, sampsPerThumbSample, levelData, chans) && isPositiveAndBelow (channelNum, numChannelsCached)) { - const Rectangle clip (g.getClipBounds().getIntersection (area.withWidth (jmin (numSamplesCached, area.getWidth())))); + auto clip = g.getClipBounds().getIntersection (area.withWidth (jmin (numSamplesCached, area.getWidth()))); if (! clip.isEmpty()) { - const float topY = (float) area.getY(); - const float bottomY = (float) area.getBottom(); - const float midY = (topY + bottomY) * 0.5f; - const float vscale = verticalZoomFactor * (bottomY - topY) / 256.0f; + auto topY = (float) area.getY(); + auto bottomY = (float) area.getBottom(); + auto midY = (topY + bottomY) * 0.5f; + auto vscale = verticalZoomFactor * (bottomY - topY) / 256.0f; - const MinMaxValue* cacheData = getData (channelNum, clip.getX() - area.getX()); + auto* cacheData = getData (channelNum, clip.getX() - area.getX()); RectangleList waveform; waveform.ensureStorageAllocated (clip.getWidth()); - float x = (float) clip.getX(); + auto x = (float) clip.getX(); for (int w = clip.getWidth(); --w >= 0;) { if (cacheData->isNonZero()) { - const float top = jmax (midY - cacheData->getMaxValue() * vscale - 0.3f, topY); - const float bottom = jmin (midY - cacheData->getMinValue() * vscale + 0.3f, bottomY); + auto top = jmax (midY - cacheData->getMaxValue() * vscale - 0.3f, topY); + auto bottom = jmin (midY - cacheData->getMinValue() * vscale + 0.3f, bottomY); waveform.addWithoutMerging (Rectangle (x, top, 1.0f, bottom - top)); } @@ -431,15 +425,15 @@ public: private: Array data; - double cachedStart, cachedTimePerPixel; - int numChannelsCached, numSamplesCached; - bool cacheNeedsRefilling; + double cachedStart = 0, cachedTimePerPixel = 0; + int numChannelsCached = 0, numSamplesCached = 0; + bool cacheNeedsRefilling = true; - bool refillCache (const int numSamples, double startTime, const double endTime, - const double rate, const int numChans, const int sampsPerThumbSample, + bool refillCache (int numSamples, double startTime, double endTime, + double rate, int numChans, int sampsPerThumbSample, LevelDataSource* levelData, const OwnedArray& chans) { - const double timePerPixel = (endTime - startTime) / numSamples; + auto timePerPixel = (endTime - startTime) / numSamples; if (numSamples <= 0 || timePerPixel <= 0.0 || rate <= 0) { @@ -466,13 +460,13 @@ private: if (timePerPixel * rate <= sampsPerThumbSample && levelData != nullptr) { - int sample = roundToInt (startTime * rate); - Array > levels; + auto sample = roundToInt (startTime * rate); + Array> levels; int i; for (i = 0; i < numSamples; ++i) { - const int nextSample = roundToInt ((startTime + timePerPixel) * rate); + auto nextSample = roundToInt ((startTime + timePerPixel) * rate); if (sample >= 0) { @@ -485,7 +479,7 @@ private: { levelData->getLevels (sample, jmax (1, nextSample - sample), levels); - const int totalChans = jmin (levels.size(), numChannelsCached); + auto totalChans = jmin (levels.size(), numChannelsCached); for (int chan = 0; chan < totalChans; ++chan) getData (chan, i)->setFloat (levels.getReference (chan)); @@ -507,14 +501,14 @@ private: ThumbData* channelData = chans.getUnchecked (channelNum); MinMaxValue* cacheData = getData (channelNum, 0); - const double timeToThumbSampleFactor = rate / (double) sampsPerThumbSample; + auto timeToThumbSampleFactor = rate / (double) sampsPerThumbSample; startTime = cachedStart; - int sample = roundToInt (startTime * timeToThumbSampleFactor); + auto sample = roundToInt (startTime * timeToThumbSampleFactor); for (int i = numSamples; --i >= 0;) { - const int nextSample = roundToInt ((startTime + timePerPixel) * timeToThumbSampleFactor); + auto nextSample = roundToInt ((startTime + timePerPixel) * timeToThumbSampleFactor); channelData->getMinMax (sample, nextSample, *cacheData); @@ -538,7 +532,7 @@ private: void ensureSize (const int numSamples) { - const int itemsRequired = numSamples * numChannelsCached; + auto itemsRequired = numSamples * numChannelsCached; if (data.size() < itemsRequired) data.insertMultiple (-1, MinMaxValue(), itemsRequired - data.size()); @@ -552,11 +546,7 @@ AudioThumbnail::AudioThumbnail (const int originalSamplesPerThumbnailSample, : formatManagerToUse (formatManager), cache (cacheToUse), window (new CachedWindow()), - samplesPerThumbSample (originalSamplesPerThumbnailSample), - totalSamples (0), - numSamplesFinished (0), - numChannels (0), - sampleRate (0) + samplesPerThumbSample (originalSamplesPerThumbnailSample) { } @@ -710,26 +700,26 @@ void AudioThumbnail::addBlock (const int64 startSample, const AudioSampleBuffer& && startOffsetInBuffer >= 0 && startOffsetInBuffer + numSamples <= incoming.getNumSamples()); - const int firstThumbIndex = (int) (startSample / samplesPerThumbSample); - const int lastThumbIndex = (int) ((startSample + numSamples + (samplesPerThumbSample - 1)) / samplesPerThumbSample); - const int numToDo = lastThumbIndex - firstThumbIndex; + auto firstThumbIndex = (int) (startSample / samplesPerThumbSample); + auto lastThumbIndex = (int) ((startSample + numSamples + (samplesPerThumbSample - 1)) / samplesPerThumbSample); + auto numToDo = lastThumbIndex - firstThumbIndex; if (numToDo > 0) { - const int numChans = jmin (channels.size(), incoming.getNumChannels()); + auto numChans = jmin (channels.size(), incoming.getNumChannels()); - const HeapBlock thumbData ((size_t) (numToDo * numChans)); - const HeapBlock thumbChannels ((size_t) numChans); + const HeapBlock thumbData (numToDo * numChans); + const HeapBlock thumbChannels (numChans); for (int chan = 0; chan < numChans; ++chan) { - const float* const sourceData = incoming.getReadPointer (chan, startOffsetInBuffer); - MinMaxValue* const dest = thumbData + numToDo * chan; + auto* sourceData = incoming.getReadPointer (chan, startOffsetInBuffer); + auto* dest = thumbData + numToDo * chan; thumbChannels [chan] = dest; for (int i = 0; i < numToDo; ++i) { - const int start = i * samplesPerThumbSample; + auto start = i * samplesPerThumbSample; dest[i].setFloat (FloatVectorOperations::findMinAndMax (sourceData + start, jmin (samplesPerThumbSample, numSamples - start))); } } @@ -745,8 +735,8 @@ void AudioThumbnail::setLevels (const MinMaxValue* const* values, int thumbIndex for (int i = jmin (numChans, channels.size()); --i >= 0;) channels.getUnchecked(i)->write (values[i], thumbIndex, numValues); - const int64 start = thumbIndex * (int64) samplesPerThumbSample; - const int64 end = (thumbIndex + numValues) * (int64) samplesPerThumbSample; + auto start = thumbIndex * (int64) samplesPerThumbSample; + auto end = (thumbIndex + numValues) * (int64) samplesPerThumbSample; if (numSamplesFinished >= start && end > numSamplesFinished) numSamplesFinished = end; @@ -787,23 +777,23 @@ float AudioThumbnail::getApproximatePeak() const const ScopedLock sl (lock); int peak = 0; - for (int i = channels.size(); --i >= 0;) - peak = jmax (peak, channels.getUnchecked(i)->getPeak()); + for (auto* c : channels) + peak = jmax (peak, c->getPeak()); return jlimit (0, 127, peak) / 127.0f; } -void AudioThumbnail::getApproximateMinMax (const double startTime, const double endTime, const int channelIndex, +void AudioThumbnail::getApproximateMinMax (double startTime, double endTime, int channelIndex, float& minValue, float& maxValue) const noexcept { const ScopedLock sl (lock); MinMaxValue result; - const ThumbData* const data = channels [channelIndex]; + auto* data = channels [channelIndex]; if (data != nullptr && sampleRate > 0) { - const int firstThumbIndex = (int) ((startTime * sampleRate) / samplesPerThumbSample); - const int lastThumbIndex = (int) (((endTime * sampleRate) + samplesPerThumbSample - 1) / samplesPerThumbSample); + auto firstThumbIndex = (int) ((startTime * sampleRate) / samplesPerThumbSample); + auto lastThumbIndex = (int) (((endTime * sampleRate) + samplesPerThumbSample - 1) / samplesPerThumbSample); data->getMinMax (jmax (0, firstThumbIndex), lastThumbIndex, result); } @@ -826,10 +816,10 @@ void AudioThumbnail::drawChannels (Graphics& g, const Rectangle& area, doub { for (int i = 0; i < numChannels; ++i) { - const int y1 = roundToInt ((i * area.getHeight()) / numChannels); - const int y2 = roundToInt (((i + 1) * area.getHeight()) / numChannels); + auto y1 = roundToInt ((i * area.getHeight()) / numChannels); + auto y2 = roundToInt (((i + 1) * area.getHeight()) / numChannels); - drawChannel (g, Rectangle (area.getX(), area.getY() + y1, area.getWidth(), y2 - y1), + drawChannel (g, { area.getX(), area.getY() + y1, area.getWidth(), y2 - y1 }, startTimeSeconds, endTimeSeconds, i, verticalZoomFactor); } } diff --git a/modules/juce_audio_utils/gui/juce_AudioThumbnail.h b/modules/juce_audio_utils/gui/juce_AudioThumbnail.h index ecfc42a40e..3121ab2c63 100644 --- a/modules/juce_audio_utils/gui/juce_AudioThumbnail.h +++ b/modules/juce_audio_utils/gui/juce_AudioThumbnail.h @@ -210,10 +210,10 @@ private: ScopedPointer window; OwnedArray channels; - int32 samplesPerThumbSample; - int64 totalSamples, numSamplesFinished; - int32 numChannels; - double sampleRate; + int32 samplesPerThumbSample = 0; + int64 totalSamples = 0, numSamplesFinished = 0; + int32 numChannels = 0; + double sampleRate = 0; CriticalSection lock; void clearChannelData(); diff --git a/modules/juce_audio_utils/players/juce_AudioProcessorPlayer.cpp b/modules/juce_audio_utils/players/juce_AudioProcessorPlayer.cpp index 9bfe2ca23c..66112eb604 100644 --- a/modules/juce_audio_utils/players/juce_AudioProcessorPlayer.cpp +++ b/modules/juce_audio_utils/players/juce_AudioProcessorPlayer.cpp @@ -187,7 +187,7 @@ void AudioProcessorPlayer::audioDeviceAboutToStart (AudioIODevice* const device) numOutputChans = numChansOut; messageCollector.reset (sampleRate); - channels.calloc ((size_t) jmax (numChansIn, numChansOut) + 2); + channels.calloc (jmax (numChansIn, numChansOut) + 2); if (processor != nullptr) { diff --git a/modules/juce_core/maths/juce_Expression.cpp b/modules/juce_core/maths/juce_Expression.cpp index afab1ae9d6..3c90388edf 100644 --- a/modules/juce_core/maths/juce_Expression.cpp +++ b/modules/juce_core/maths/juce_Expression.cpp @@ -245,10 +245,12 @@ struct Expression::Helpers { checkRecursionDepth (recursionDepth); double result = 0; - const int numParams = parameters.size(); + auto numParams = parameters.size(); + if (numParams > 0) { - HeapBlock params ((size_t) numParams); + HeapBlock params (numParams); + for (int i = 0; i < numParams; ++i) params[i] = parameters.getReference(i).term->resolve (scope, recursionDepth + 1)->toDouble(); diff --git a/modules/juce_core/memory/juce_HeapBlock.h b/modules/juce_core/memory/juce_HeapBlock.h index a469d58905..241cf759d0 100644 --- a/modules/juce_core/memory/juce_HeapBlock.h +++ b/modules/juce_core/memory/juce_HeapBlock.h @@ -90,7 +90,7 @@ public: After creation, you can resize the array using the malloc(), calloc(), or realloc() methods. */ - HeapBlock() noexcept : data (nullptr) + HeapBlock() noexcept { } @@ -102,8 +102,9 @@ public: If you want an array of zero values, you can use the calloc() method or the other constructor that takes an InitialisationState parameter. */ - explicit HeapBlock (const size_t numElements) - : data (static_cast (std::malloc (numElements * sizeof (ElementType)))) + template + explicit HeapBlock (SizeType numElements) + : data (static_cast (std::malloc (static_cast (numElements) * sizeof (ElementType)))) { throwOnAllocationFailure(); } @@ -113,10 +114,11 @@ public: The initialiseToZero parameter determines whether the new memory should be cleared, or left uninitialised. */ - HeapBlock (const size_t numElements, const bool initialiseToZero) + template + HeapBlock (SizeType numElements, bool initialiseToZero) : data (static_cast (initialiseToZero - ? std::calloc (numElements, sizeof (ElementType)) - : std::malloc (numElements * sizeof (ElementType)))) + ? std::calloc (static_cast (numElements), sizeof (ElementType)) + : std::malloc (static_cast (numElements) * sizeof (ElementType)))) { throwOnAllocationFailure(); } @@ -148,62 +150,61 @@ public: This may be a null pointer if the data hasn't yet been allocated, or if it has been freed by calling the free() method. */ - inline operator ElementType*() const noexcept { return data; } - + inline operator ElementType*() const noexcept { return data; } /** Returns a raw pointer to the allocated data. This may be a null pointer if the data hasn't yet been allocated, or if it has been freed by calling the free() method. */ - inline ElementType* get() const noexcept { return data; } + inline ElementType* get() const noexcept { return data; } /** Returns a raw pointer to the allocated data. This may be a null pointer if the data hasn't yet been allocated, or if it has been freed by calling the free() method. */ - inline ElementType* getData() const noexcept { return data; } + inline ElementType* getData() const noexcept { return data; } /** Returns a void pointer to the allocated data. This may be a null pointer if the data hasn't yet been allocated, or if it has been freed by calling the free() method. */ - inline operator void*() const noexcept { return static_cast (data); } + inline operator void*() const noexcept { return static_cast (data); } /** Returns a void pointer to the allocated data. This may be a null pointer if the data hasn't yet been allocated, or if it has been freed by calling the free() method. */ - inline operator const void*() const noexcept { return static_cast (data); } + inline operator const void*() const noexcept { return static_cast (data); } /** Lets you use indirect calls to the first element in the array. Obviously this will cause problems if the array hasn't been initialised, because it'll be referencing a null pointer. */ - inline ElementType* operator->() const noexcept { return data; } + inline ElementType* operator->() const noexcept { return data; } /** Returns a reference to one of the data elements. Obviously there's no bounds-checking here, as this object is just a dumb pointer and has no idea of the size it currently has allocated. */ template - inline ElementType& operator[] (IndexType index) const noexcept { return data [index]; } + ElementType& operator[] (IndexType index) const noexcept { return data [index]; } /** Returns a pointer to a data element at an offset from the start of the array. This is the same as doing pointer arithmetic on the raw pointer itself. */ template - inline ElementType* operator+ (IndexType index) const noexcept { return data + index; } + ElementType* operator+ (IndexType index) const noexcept { return data + index; } //============================================================================== /** Compares the pointer with another pointer. This can be handy for checking whether this is a null pointer. */ - inline bool operator== (const ElementType* const otherPointer) const noexcept { return otherPointer == data; } + inline bool operator== (const ElementType* otherPointer) const noexcept { return otherPointer == data; } /** Compares the pointer with another pointer. This can be handy for checking whether this is a null pointer. */ - inline bool operator!= (const ElementType* const otherPointer) const noexcept { return otherPointer != data; } + inline bool operator!= (const ElementType* otherPointer) const noexcept { return otherPointer != data; } //============================================================================== /** Allocates a specified amount of memory. @@ -218,20 +219,22 @@ public: The data that is allocated will be freed when this object is deleted, or when you call free() or any of the allocation methods. */ - void malloc (const size_t newNumElements, const size_t elementSize = sizeof (ElementType)) + template + void malloc (SizeType newNumElements, size_t elementSize = sizeof (ElementType)) { std::free (data); - data = static_cast (std::malloc (newNumElements * elementSize)); + data = static_cast (std::malloc (static_cast (newNumElements) * elementSize)); throwOnAllocationFailure(); } /** Allocates a specified amount of memory and clears it. This does the same job as the malloc() method, but clears the memory that it allocates. */ - void calloc (const size_t newNumElements, const size_t elementSize = sizeof (ElementType)) + template + void calloc (SizeType newNumElements, const size_t elementSize = sizeof (ElementType)) { std::free (data); - data = static_cast (std::calloc (newNumElements, elementSize)); + data = static_cast (std::calloc (static_cast (newNumElements), elementSize)); throwOnAllocationFailure(); } @@ -239,12 +242,13 @@ public: This does the same job as either malloc() or calloc(), depending on the initialiseToZero parameter. */ - void allocate (const size_t newNumElements, bool initialiseToZero) + template + void allocate (SizeType newNumElements, bool initialiseToZero) { std::free (data); data = static_cast (initialiseToZero - ? std::calloc (newNumElements, sizeof (ElementType)) - : std::malloc (newNumElements * sizeof (ElementType))); + ? std::calloc (static_cast (newNumElements), sizeof (ElementType)) + : std::malloc (static_cast (newNumElements) * sizeof (ElementType))); throwOnAllocationFailure(); } @@ -253,10 +257,11 @@ public: The semantics of this method are the same as malloc() and calloc(), but it uses realloc() to keep as much of the existing data as possible. */ - void realloc (const size_t newNumElements, const size_t elementSize = sizeof (ElementType)) + template + void realloc (SizeType newNumElements, size_t elementSize = sizeof (ElementType)) { - data = static_cast (data == nullptr ? std::malloc (newNumElements * elementSize) - : std::realloc (data, newNumElements * elementSize)); + data = static_cast (data == nullptr ? std::malloc (static_cast (newNumElements) * elementSize) + : std::realloc (data, static_cast (newNumElements) * elementSize)); throwOnAllocationFailure(); } @@ -282,9 +287,10 @@ public: Since the block has no way of knowing its own size, you must make sure that the number of elements you specify doesn't exceed the allocated size. */ - void clear (size_t numElements) noexcept + template + void clear (SizeType numElements) noexcept { - zeromem (data, sizeof (ElementType) * numElements); + zeromem (data, sizeof (ElementType) * static_cast (numElements)); } /** This typedef can be used to get the type of the heapblock's elements. */ @@ -292,7 +298,7 @@ public: private: //============================================================================== - ElementType* data; + ElementType* data = nullptr; void throwOnAllocationFailure() const { diff --git a/modules/juce_core/native/juce_android_Network.cpp b/modules/juce_core/native/juce_android_Network.cpp index 136ce47de3..5b5864ebb1 100644 --- a/modules/juce_core/native/juce_android_Network.cpp +++ b/modules/juce_core/native/juce_android_Network.cpp @@ -260,7 +260,7 @@ static void findIPAddresses (int sock, Array& result) do { bufferSize *= 2; - buffer.calloc ((size_t) bufferSize); + buffer.calloc (bufferSize); cfg.ifc_len = bufferSize; cfg.ifc_buf = buffer; diff --git a/modules/juce_core/native/juce_linux_Network.cpp b/modules/juce_core/native/juce_linux_Network.cpp index 2ca8d51200..e02a369690 100644 --- a/modules/juce_core/native/juce_linux_Network.cpp +++ b/modules/juce_core/native/juce_linux_Network.cpp @@ -239,8 +239,8 @@ public: return false; int64 numBytesToSkip = wantedPos - position; - const int skipBufferSize = (int) jmin (numBytesToSkip, (int64) 16384); - HeapBlock temp ((size_t) skipBufferSize); + auto skipBufferSize = (int) jmin (numBytesToSkip, (int64) 16384); + HeapBlock temp (skipBufferSize); while (numBytesToSkip > 0 && ! isExhausted()) numBytesToSkip -= read (temp, (int) jmin (numBytesToSkip, (int64) skipBufferSize)); diff --git a/modules/juce_core/native/juce_mac_Network.mm b/modules/juce_core/native/juce_mac_Network.mm index f182a42b52..1e3ec34e07 100644 --- a/modules/juce_core/native/juce_mac_Network.mm +++ b/modules/juce_core/native/juce_mac_Network.mm @@ -1055,9 +1055,9 @@ public: if (wantedPos < position) return false; - int64 numBytesToSkip = wantedPos - position; - const int skipBufferSize = (int) jmin (numBytesToSkip, (int64) 16384); - HeapBlock temp ((size_t) skipBufferSize); + auto numBytesToSkip = wantedPos - position; + auto skipBufferSize = (int) jmin (numBytesToSkip, (int64) 16384); + HeapBlock temp (skipBufferSize); while (numBytesToSkip > 0 && ! isExhausted()) numBytesToSkip -= read (temp, (int) jmin (numBytesToSkip, (int64) skipBufferSize)); diff --git a/modules/juce_core/native/juce_mac_Strings.mm b/modules/juce_core/native/juce_mac_Strings.mm index b8a479ead8..61f30118cd 100644 --- a/modules/juce_core/native/juce_mac_Strings.mm +++ b/modules/juce_core/native/juce_mac_Strings.mm @@ -32,7 +32,7 @@ String String::fromCFString (CFStringRef cfString) CFIndex bytesNeeded = 0; CFStringGetBytes (cfString, range, kCFStringEncodingUTF8, 0, false, nullptr, 0, &bytesNeeded); - HeapBlock utf8 ((size_t) bytesNeeded + 1); + HeapBlock utf8 (bytesNeeded + 1); CFStringGetBytes (cfString, range, kCFStringEncodingUTF8, 0, false, utf8, bytesNeeded + 1, nullptr); return String (CharPointer_UTF8 ((const CharPointer_UTF8::CharType*) utf8.get()), diff --git a/modules/juce_core/native/juce_win32_Network.cpp b/modules/juce_core/native/juce_win32_Network.cpp index bdc7dc9c4d..8c4716b298 100644 --- a/modules/juce_core/native/juce_win32_Network.cpp +++ b/modules/juce_core/native/juce_win32_Network.cpp @@ -88,7 +88,7 @@ public: for (;;) { - HeapBlock buffer ((size_t) bufferSizeBytes); + HeapBlock buffer (bufferSizeBytes); if (HttpQueryInfo (request, HTTP_QUERY_RAW_HEADERS_CRLF, buffer.getData(), &bufferSizeBytes, 0)) { @@ -216,8 +216,8 @@ public: return false; int64 numBytesToSkip = wantedPos - position; - const int skipBufferSize = (int) jmin (numBytesToSkip, (int64) 16384); - HeapBlock temp ((size_t) skipBufferSize); + auto skipBufferSize = (int) jmin (numBytesToSkip, (int64) 16384); + HeapBlock temp (skipBufferSize); while (numBytesToSkip > 0 && ! isExhausted()) numBytesToSkip -= read (temp, (int) jmin (numBytesToSkip, (int64) skipBufferSize)); @@ -645,7 +645,7 @@ bool JUCE_CALLTYPE Process::openEmailWithAttachments (const String& targetEmailA message.lpRecips = &recip; HeapBlock files; - files.calloc ((size_t) filesToAttach.size()); + files.calloc (filesToAttach.size()); message.nFileCount = (ULONG) filesToAttach.size(); message.lpFiles = files; diff --git a/modules/juce_core/streams/juce_BufferedInputStream.cpp b/modules/juce_core/streams/juce_BufferedInputStream.cpp index 8af122a694..d53484fe22 100644 --- a/modules/juce_core/streams/juce_BufferedInputStream.cpp +++ b/modules/juce_core/streams/juce_BufferedInputStream.cpp @@ -44,7 +44,7 @@ BufferedInputStream::BufferedInputStream (InputStream* sourceStream, int size, b position (sourceStream->getPosition()), bufferStart (position) { - buffer.malloc ((size_t) bufferSize); + buffer.malloc (bufferSize); } BufferedInputStream::BufferedInputStream (InputStream& sourceStream, int size) diff --git a/modules/juce_core/streams/juce_InputStream.cpp b/modules/juce_core/streams/juce_InputStream.cpp index a27f5cfc1d..a01a12ff72 100644 --- a/modules/juce_core/streams/juce_InputStream.cpp +++ b/modules/juce_core/streams/juce_InputStream.cpp @@ -177,7 +177,7 @@ String InputStream::readString() String InputStream::readNextLine() { MemoryBlock buffer (256); - char* data = static_cast (buffer.getData()); + auto* data = static_cast (buffer.getData()); size_t i = 0; while ((data[i] = readByte()) != 0) @@ -223,8 +223,8 @@ void InputStream::skipNextBytes (int64 numBytesToSkip) { if (numBytesToSkip > 0) { - const int skipBufferSize = (int) jmin (numBytesToSkip, (int64) 16384); - HeapBlock temp ((size_t) skipBufferSize); + auto skipBufferSize = (int) jmin (numBytesToSkip, (int64) 16384); + HeapBlock temp (skipBufferSize); while (numBytesToSkip > 0 && ! isExhausted()) numBytesToSkip -= read (temp, (int) jmin (numBytesToSkip, (int64) skipBufferSize)); diff --git a/modules/juce_core/xml/juce_XmlElement.h b/modules/juce_core/xml/juce_XmlElement.h index 33f86744ec..fd1362fb31 100644 --- a/modules/juce_core/xml/juce_XmlElement.h +++ b/modules/juce_core/xml/juce_XmlElement.h @@ -632,11 +632,11 @@ public: void sortChildElements (ElementComparator& comparator, bool retainOrderOfEquivalentItems = false) { - const int num = getNumChildElements(); + auto num = getNumChildElements(); if (num > 1) { - HeapBlock elems ((size_t) num); + HeapBlock elems (num); getChildElementsAsArray (elems); sortArray (comparator, (XmlElement**) elems, 0, num - 1, retainOrderOfEquivalentItems); reorderChildElements (elems, num); diff --git a/modules/juce_graphics/colour/juce_ColourGradient.cpp b/modules/juce_graphics/colour/juce_ColourGradient.cpp index c025468e8d..6ed948c14b 100644 --- a/modules/juce_graphics/colour/juce_ColourGradient.cpp +++ b/modules/juce_graphics/colour/juce_ColourGradient.cpp @@ -37,20 +37,15 @@ ColourGradient::ColourGradient() noexcept #endif } -ColourGradient::ColourGradient (Colour colour1, const float x1, const float y1, - Colour colour2, const float x2, const float y2, - const bool radial) - : point1 (x1, y1), - point2 (x2, y2), - isRadial (radial) +ColourGradient::ColourGradient (Colour colour1, float x1, float y1, + Colour colour2, float x2, float y2, bool radial) + : ColourGradient (colour1, Point (x1, y1), + colour2, Point (x2, y2), radial) { - colours.add (ColourPoint (0.0, colour1)); - colours.add (ColourPoint (1.0, colour2)); } ColourGradient::ColourGradient (Colour colour1, Point p1, - Colour colour2, Point p2, - const bool radial) + Colour colour2, Point p2, bool radial) : point1 (p1), point2 (p2), isRadial (radial) @@ -92,7 +87,7 @@ int ColourGradient::addColour (const double proportionAlongGradient, Colour colo return 0; } - const double pos = jmin (1.0, proportionAlongGradient); + auto pos = jmin (1.0, proportionAlongGradient); int i; for (i = 0; i < colours.size(); ++i) @@ -111,11 +106,8 @@ void ColourGradient::removeColour (int index) void ColourGradient::multiplyOpacity (const float multiplier) noexcept { - for (int i = 0; i < colours.size(); ++i) - { - Colour& c = colours.getReference(i).colour; - c = c.withMultipliedAlpha (multiplier); - } + for (auto& c : colours) + c.colour = c.colour.withMultipliedAlpha (multiplier); } //============================================================================== @@ -137,7 +129,7 @@ Colour ColourGradient::getColour (const int index) const noexcept if (isPositiveAndBelow (index, colours.size())) return colours.getReference (index).colour; - return Colour(); + return {}; } void ColourGradient::setColour (int index, Colour newColour) noexcept @@ -175,14 +167,14 @@ void ColourGradient::createLookupTable (PixelARGB* const lookupTable, const int jassert (numEntries > 0); jassert (colours.getReference(0).position == 0.0); // The first colour specified has to go at position 0 - PixelARGB pix1 (colours.getReference (0).colour.getPixelARGB()); + auto pix1 = colours.getReference (0).colour.getPixelARGB(); int index = 0; for (int j = 1; j < colours.size(); ++j) { - const ColourPoint& p = colours.getReference (j); - const int numToDo = roundToInt (p.position * (numEntries - 1)) - index; - const PixelARGB pix2 (p.colour.getPixelARGB()); + auto& p = colours.getReference (j); + auto numToDo = roundToInt (p.position * (numEntries - 1)) - index; + auto pix2 = p.colour.getPixelARGB(); for (int i = 0; i < numToDo; ++i) { @@ -205,18 +197,18 @@ int ColourGradient::createLookupTable (const AffineTransform& transform, HeapBlo JUCE_COLOURGRADIENT_CHECK_COORDS_INITIALISED // Trying to use this object without setting its coordinates? jassert (colours.size() >= 2); - const int numEntries = jlimit (1, jmax (1, (colours.size() - 1) << 8), - 3 * (int) point1.transformedBy (transform) - .getDistanceFrom (point2.transformedBy (transform))); - lookupTable.malloc ((size_t) numEntries); + auto numEntries = jlimit (1, jmax (1, (colours.size() - 1) << 8), + 3 * (int) point1.transformedBy (transform) + .getDistanceFrom (point2.transformedBy (transform))); + lookupTable.malloc (numEntries); createLookupTable (lookupTable, numEntries); return numEntries; } bool ColourGradient::isOpaque() const noexcept { - for (int i = 0; i < colours.size(); ++i) - if (! colours.getReference(i).colour.isOpaque()) + for (auto& c : colours) + if (! c.colour.isOpaque()) return false; return true; @@ -224,8 +216,8 @@ bool ColourGradient::isOpaque() const noexcept bool ColourGradient::isInvisible() const noexcept { - for (int i = 0; i < colours.size(); ++i) - if (! colours.getReference(i).colour.isTransparent()) + for (auto& c : colours) + if (! c.colour.isTransparent()) return false; return true; diff --git a/modules/juce_graphics/image_formats/juce_PNGLoader.cpp b/modules/juce_graphics/image_formats/juce_PNGLoader.cpp index ee06273171..5a2a376ede 100644 --- a/modules/juce_graphics/image_formats/juce_PNGLoader.cpp +++ b/modules/juce_graphics/image_formats/juce_PNGLoader.cpp @@ -545,7 +545,7 @@ bool PNGImageFormat::writeImageToStream (const Image& image, OutputStream& out) PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); - HeapBlock rowData ((size_t) width * 4); + HeapBlock rowData (width * 4); png_color_8 sig_bit; sig_bit.red = 8; diff --git a/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm b/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm index 63e7f89259..4de9851f61 100644 --- a/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm +++ b/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm @@ -247,7 +247,7 @@ bool CoreGraphicsContext::clipToRectangleListWithoutTest (const RectangleList rects (numRects); int i = 0; @@ -558,7 +558,7 @@ void CoreGraphicsContext::drawLine (const Line& line) void CoreGraphicsContext::fillRectList (const RectangleList& list) { - HeapBlock rects ((size_t) list.getNumRectangles()); + HeapBlock rects (list.getNumRectangles()); size_t num = 0; diff --git a/modules/juce_graphics/native/juce_mac_Fonts.mm b/modules/juce_graphics/native/juce_mac_Fonts.mm index 19b3b38f3f..21e595afea 100644 --- a/modules/juce_graphics/native/juce_mac_Fonts.mm +++ b/modules/juce_graphics/native/juce_mac_Fonts.mm @@ -149,7 +149,7 @@ namespace CoreTextTypeLayout { if (advances == nullptr) { - local.malloc ((size_t) numGlyphs); + local.malloc (numGlyphs); CTRunGetAdvances (run, CFRangeMake (0, 0), local); advances = local; } diff --git a/modules/juce_gui_basics/layout/juce_FlexBox.cpp b/modules/juce_gui_basics/layout/juce_FlexBox.cpp index d647b15a3c..a6b9e3177e 100644 --- a/modules/juce_gui_basics/layout/juce_FlexBox.cpp +++ b/modules/juce_gui_basics/layout/juce_FlexBox.cpp @@ -37,8 +37,8 @@ struct FlexBoxLayoutCalculation || fb.flexDirection == FlexBox::Direction::rowReverse), containerLineLength (isRowDirection ? parentWidth : parentHeight) { - lineItems.calloc ((size_t) (numItems * numItems)); - lineInfo.calloc ((size_t) numItems); + lineItems.calloc (numItems * numItems); + lineInfo.calloc (numItems); } struct ItemWithState diff --git a/modules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp b/modules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp index 0182cf4776..865b5143c1 100644 --- a/modules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp @@ -578,7 +578,7 @@ public: const int pixStride = 2; const int stride = ((w * pixStride + 3) & ~3); - imageData16Bit.malloc ((size_t) (stride * h)); + imageData16Bit.malloc (stride * h); xImage->data = imageData16Bit; xImage->bitmap_pad = 16; xImage->depth = pixStride * 8; @@ -1946,7 +1946,7 @@ public: void setIcon (const Image& newIcon) override { const int dataSize = newIcon.getWidth() * newIcon.getHeight() + 2; - HeapBlock data ((size_t) dataSize); + HeapBlock data (dataSize); int index = 0; data[index++] = (unsigned long) newIcon.getWidth(); diff --git a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp index 695d2fd0aa..8c487c20b2 100644 --- a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp @@ -3492,7 +3492,7 @@ private: if (attributeSizeBytes > 0) { // Get attributes (8 bit flag per character): - HeapBlock attributes ((size_t) attributeSizeBytes); + HeapBlock attributes (attributeSizeBytes); ImmGetCompositionString (hImc, GCS_COMPATTR, attributes, (DWORD) attributeSizeBytes); selectionStart = 0; diff --git a/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp b/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp index 4aaeb2ffb5..9d2ecaa352 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp @@ -299,7 +299,7 @@ private: : area (et.getMaximumBounds().withSize (nextPowerOfTwo (et.getMaximumBounds().getWidth()), nextPowerOfTwo (et.getMaximumBounds().getHeight()))) { - data.calloc ((size_t) (area.getWidth() * area.getHeight())); + data.calloc (area.getWidth() * area.getHeight()); et.iterate (*this); } diff --git a/modules/juce_opengl/opengl/juce_OpenGLImage.cpp b/modules/juce_opengl/opengl/juce_OpenGLImage.cpp index 4b748a2eb6..b4deaaf2cd 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLImage.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLImage.cpp @@ -103,8 +103,8 @@ private: static void verticalRowFlip (PixelARGB* const data, const int w, const int h) { - HeapBlock tempRow ((size_t) w); - const size_t rowSize = sizeof (PixelARGB) * (size_t) w; + HeapBlock tempRow (w); + auto rowSize = sizeof (PixelARGB) * (size_t) w; for (int y = 0; y < h / 2; ++y) { @@ -125,8 +125,8 @@ private: void write (const PixelARGB* const data) const noexcept { - HeapBlock invertedCopy ((size_t) (area.getWidth() * area.getHeight())); - const size_t rowSize = sizeof (PixelARGB) * (size_t) area.getWidth(); + HeapBlock invertedCopy (area.getWidth() * area.getHeight()); + auto rowSize = sizeof (PixelARGB) * (size_t) area.getWidth(); for (int y = 0; y < area.getHeight(); ++y) memcpy (invertedCopy + area.getWidth() * y, diff --git a/modules/juce_opengl/opengl/juce_OpenGLTexture.cpp b/modules/juce_opengl/opengl/juce_OpenGLTexture.cpp index d29adccc72..4fdeeee745 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLTexture.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLTexture.cpp @@ -107,12 +107,12 @@ struct Flipper static void flip (HeapBlock& dataCopy, const uint8* srcData, const int lineStride, const int w, const int h) { - dataCopy.malloc ((size_t) (w * h)); + dataCopy.malloc (w * h); for (int y = 0; y < h; ++y) { - const PixelType* src = (const PixelType*) srcData; - PixelARGB* const dst = (PixelARGB*) (dataCopy + w * (h - 1 - y)); + auto* src = (const PixelType*) srcData; + auto* dst = (PixelARGB*) (dataCopy + w * (h - 1 - y)); for (int x = 0; x < w; ++x) dst[x].set (src[x]);