| @@ -1092,7 +1092,7 @@ private: | |||
| } | |||
| else | |||
| { | |||
| allocatedData.malloc ((size_t) numChannels + 1, sizeof (Type*)); | |||
| allocatedData.malloc (numChannels + 1, sizeof (Type*)); | |||
| channels = reinterpret_cast<Type**> (allocatedData.get()); | |||
| } | |||
| @@ -1139,8 +1139,8 @@ public: | |||
| const int range = random.nextBool() ? 500 : 10; | |||
| const int num = random.nextInt (range) + 1; | |||
| HeapBlock<ValueType> buffer1 ((size_t) num + 16), buffer2 ((size_t) num + 16); | |||
| HeapBlock<int> buffer3 ((size_t) num + 16); | |||
| HeapBlock<ValueType> buffer1 (num + 16), buffer2 (num + 16); | |||
| HeapBlock<int> buffer3 (num + 16); | |||
| #if JUCE_ARM | |||
| ValueType* const data1 = buffer1; | |||
| @@ -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; | |||
| } | |||
| @@ -638,7 +638,7 @@ bool MidiMessage::isSysEx() const noexcept | |||
| MidiMessage MidiMessage::createSysExMessage (const void* sysexData, const int dataSize) | |||
| { | |||
| HeapBlock<uint8> m ((size_t) dataSize + 2); | |||
| HeapBlock<uint8> m (dataSize + 2); | |||
| m[0] = 0xf0; | |||
| memcpy (m + 1, sysexData, (size_t) dataSize); | |||
| @@ -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(); | |||
| @@ -316,8 +316,8 @@ private: | |||
| if (snd_midi_event_new (maxEventSize, &midiParser) >= 0) | |||
| { | |||
| const int numPfds = snd_seq_poll_descriptors_count (seqHandle, POLLIN); | |||
| HeapBlock<pollfd> pfd ((size_t) numPfds); | |||
| auto numPfds = snd_seq_poll_descriptors_count (seqHandle, POLLIN); | |||
| HeapBlock<pollfd> pfd (numPfds); | |||
| snd_seq_poll_descriptors (seqHandle, pfd, (unsigned int) numPfds, POLLIN); | |||
| HeapBlock<uint8> buffer (maxEventSize); | |||
| @@ -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; | |||
| @@ -440,7 +440,7 @@ public: | |||
| HeapBlock<int*> channels; | |||
| HeapBlock<int> 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; | |||
| @@ -168,7 +168,7 @@ void AudioFormatReader::read (AudioSampleBuffer* buffer, | |||
| } | |||
| else | |||
| { | |||
| HeapBlock<int*> chans ((size_t) numTargetChannels + 1); | |||
| HeapBlock<int*> chans (numTargetChannels + 1); | |||
| readChannels (*this, chans, buffer, startSample, numSamples, readerStartSample, numTargetChannels); | |||
| } | |||
| @@ -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<InputSource> source; | |||
| ScopedPointer<AudioFormatReader> 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<MinMaxValue> levelData ((size_t) numThumbSamps * numChannels); | |||
| HeapBlock<MinMaxValue> levelData ((unsigned int) numThumbSamps * numChannels); | |||
| HeapBlock<MinMaxValue*> levels (numChannels); | |||
| for (int i = 0; i < (int) numChannels; ++i) | |||
| levels[i] = levelData + i * numThumbSamps; | |||
| HeapBlock<Range<float> > levelsRead (numChannels); | |||
| HeapBlock<Range<float>> 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<MinMaxValue> 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<int> 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<float> 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<float> (x, top, 1.0f, bottom - top)); | |||
| } | |||
| @@ -431,15 +425,15 @@ public: | |||
| private: | |||
| Array<MinMaxValue> 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<ThumbData>& 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<Range<float> > levels; | |||
| auto sample = roundToInt (startTime * rate); | |||
| Array<Range<float>> 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<MinMaxValue> thumbData ((size_t) (numToDo * numChans)); | |||
| const HeapBlock<MinMaxValue*> thumbChannels ((size_t) numChans); | |||
| const HeapBlock<MinMaxValue> thumbData (numToDo * numChans); | |||
| const HeapBlock<MinMaxValue*> 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<int>& 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<int> (area.getX(), area.getY() + y1, area.getWidth(), y2 - y1), | |||
| drawChannel (g, { area.getX(), area.getY() + y1, area.getWidth(), y2 - y1 }, | |||
| startTimeSeconds, endTimeSeconds, i, verticalZoomFactor); | |||
| } | |||
| } | |||
| @@ -210,10 +210,10 @@ private: | |||
| ScopedPointer<CachedWindow> window; | |||
| OwnedArray<ThumbData> 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(); | |||
| @@ -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) | |||
| { | |||
| @@ -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<double> params ((size_t) numParams); | |||
| HeapBlock<double> params (numParams); | |||
| for (int i = 0; i < numParams; ++i) | |||
| params[i] = parameters.getReference(i).term->resolve (scope, recursionDepth + 1)->toDouble(); | |||
| @@ -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<ElementType*> (std::malloc (numElements * sizeof (ElementType)))) | |||
| template <typename SizeType> | |||
| explicit HeapBlock (SizeType numElements) | |||
| : data (static_cast<ElementType*> (std::malloc (static_cast<size_t> (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 <typename SizeType> | |||
| HeapBlock (SizeType numElements, bool initialiseToZero) | |||
| : data (static_cast<ElementType*> (initialiseToZero | |||
| ? std::calloc (numElements, sizeof (ElementType)) | |||
| : std::malloc (numElements * sizeof (ElementType)))) | |||
| ? std::calloc (static_cast<size_t> (numElements), sizeof (ElementType)) | |||
| : std::malloc (static_cast<size_t> (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<void*> (data); } | |||
| inline operator void*() const noexcept { return static_cast<void*> (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<const void*> (data); } | |||
| inline operator const void*() const noexcept { return static_cast<const void*> (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 <typename IndexType> | |||
| 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 <typename IndexType> | |||
| 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 <typename SizeType> | |||
| void malloc (SizeType newNumElements, size_t elementSize = sizeof (ElementType)) | |||
| { | |||
| std::free (data); | |||
| data = static_cast<ElementType*> (std::malloc (newNumElements * elementSize)); | |||
| data = static_cast<ElementType*> (std::malloc (static_cast<size_t> (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 <typename SizeType> | |||
| void calloc (SizeType newNumElements, const size_t elementSize = sizeof (ElementType)) | |||
| { | |||
| std::free (data); | |||
| data = static_cast<ElementType*> (std::calloc (newNumElements, elementSize)); | |||
| data = static_cast<ElementType*> (std::calloc (static_cast<size_t> (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 <typename SizeType> | |||
| void allocate (SizeType newNumElements, bool initialiseToZero) | |||
| { | |||
| std::free (data); | |||
| data = static_cast<ElementType*> (initialiseToZero | |||
| ? std::calloc (newNumElements, sizeof (ElementType)) | |||
| : std::malloc (newNumElements * sizeof (ElementType))); | |||
| ? std::calloc (static_cast<size_t> (newNumElements), sizeof (ElementType)) | |||
| : std::malloc (static_cast<size_t> (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 <typename SizeType> | |||
| void realloc (SizeType newNumElements, size_t elementSize = sizeof (ElementType)) | |||
| { | |||
| data = static_cast<ElementType*> (data == nullptr ? std::malloc (newNumElements * elementSize) | |||
| : std::realloc (data, newNumElements * elementSize)); | |||
| data = static_cast<ElementType*> (data == nullptr ? std::malloc (static_cast<size_t> (newNumElements) * elementSize) | |||
| : std::realloc (data, static_cast<size_t> (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 <typename SizeType> | |||
| void clear (SizeType numElements) noexcept | |||
| { | |||
| zeromem (data, sizeof (ElementType) * numElements); | |||
| zeromem (data, sizeof (ElementType) * static_cast<size_t> (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 | |||
| { | |||
| @@ -260,7 +260,7 @@ static void findIPAddresses (int sock, Array<IPAddress>& result) | |||
| do | |||
| { | |||
| bufferSize *= 2; | |||
| buffer.calloc ((size_t) bufferSize); | |||
| buffer.calloc (bufferSize); | |||
| cfg.ifc_len = bufferSize; | |||
| cfg.ifc_buf = buffer; | |||
| @@ -239,8 +239,8 @@ public: | |||
| return false; | |||
| int64 numBytesToSkip = wantedPos - position; | |||
| const int skipBufferSize = (int) jmin (numBytesToSkip, (int64) 16384); | |||
| HeapBlock<char> temp ((size_t) skipBufferSize); | |||
| auto skipBufferSize = (int) jmin (numBytesToSkip, (int64) 16384); | |||
| HeapBlock<char> temp (skipBufferSize); | |||
| while (numBytesToSkip > 0 && ! isExhausted()) | |||
| numBytesToSkip -= read (temp, (int) jmin (numBytesToSkip, (int64) skipBufferSize)); | |||
| @@ -1055,9 +1055,9 @@ public: | |||
| if (wantedPos < position) | |||
| return false; | |||
| int64 numBytesToSkip = wantedPos - position; | |||
| const int skipBufferSize = (int) jmin (numBytesToSkip, (int64) 16384); | |||
| HeapBlock<char> temp ((size_t) skipBufferSize); | |||
| auto numBytesToSkip = wantedPos - position; | |||
| auto skipBufferSize = (int) jmin (numBytesToSkip, (int64) 16384); | |||
| HeapBlock<char> temp (skipBufferSize); | |||
| while (numBytesToSkip > 0 && ! isExhausted()) | |||
| numBytesToSkip -= read (temp, (int) jmin (numBytesToSkip, (int64) skipBufferSize)); | |||
| @@ -32,7 +32,7 @@ String String::fromCFString (CFStringRef cfString) | |||
| CFIndex bytesNeeded = 0; | |||
| CFStringGetBytes (cfString, range, kCFStringEncodingUTF8, 0, false, nullptr, 0, &bytesNeeded); | |||
| HeapBlock<UInt8> utf8 ((size_t) bytesNeeded + 1); | |||
| HeapBlock<UInt8> utf8 (bytesNeeded + 1); | |||
| CFStringGetBytes (cfString, range, kCFStringEncodingUTF8, 0, false, utf8, bytesNeeded + 1, nullptr); | |||
| return String (CharPointer_UTF8 ((const CharPointer_UTF8::CharType*) utf8.get()), | |||
| @@ -88,7 +88,7 @@ public: | |||
| for (;;) | |||
| { | |||
| HeapBlock<char> buffer ((size_t) bufferSizeBytes); | |||
| HeapBlock<char> 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<char> temp ((size_t) skipBufferSize); | |||
| auto skipBufferSize = (int) jmin (numBytesToSkip, (int64) 16384); | |||
| HeapBlock<char> 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<MapiFileDesc> files; | |||
| files.calloc ((size_t) filesToAttach.size()); | |||
| files.calloc (filesToAttach.size()); | |||
| message.nFileCount = (ULONG) filesToAttach.size(); | |||
| message.lpFiles = files; | |||
| @@ -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) | |||
| @@ -177,7 +177,7 @@ String InputStream::readString() | |||
| String InputStream::readNextLine() | |||
| { | |||
| MemoryBlock buffer (256); | |||
| char* data = static_cast<char*> (buffer.getData()); | |||
| auto* data = static_cast<char*> (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<char> temp ((size_t) skipBufferSize); | |||
| auto skipBufferSize = (int) jmin (numBytesToSkip, (int64) 16384); | |||
| HeapBlock<char> temp (skipBufferSize); | |||
| while (numBytesToSkip > 0 && ! isExhausted()) | |||
| numBytesToSkip -= read (temp, (int) jmin (numBytesToSkip, (int64) skipBufferSize)); | |||
| @@ -632,11 +632,11 @@ public: | |||
| void sortChildElements (ElementComparator& comparator, | |||
| bool retainOrderOfEquivalentItems = false) | |||
| { | |||
| const int num = getNumChildElements(); | |||
| auto num = getNumChildElements(); | |||
| if (num > 1) | |||
| { | |||
| HeapBlock<XmlElement*> elems ((size_t) num); | |||
| HeapBlock<XmlElement*> elems (num); | |||
| getChildElementsAsArray (elems); | |||
| sortArray (comparator, (XmlElement**) elems, 0, num - 1, retainOrderOfEquivalentItems); | |||
| reorderChildElements (elems, num); | |||
| @@ -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<float> (x1, y1), | |||
| colour2, Point<float> (x2, y2), radial) | |||
| { | |||
| colours.add (ColourPoint (0.0, colour1)); | |||
| colours.add (ColourPoint (1.0, colour2)); | |||
| } | |||
| ColourGradient::ColourGradient (Colour colour1, Point<float> p1, | |||
| Colour colour2, Point<float> p2, | |||
| const bool radial) | |||
| Colour colour2, Point<float> 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; | |||
| @@ -545,7 +545,7 @@ bool PNGImageFormat::writeImageToStream (const Image& image, OutputStream& out) | |||
| PNG_COMPRESSION_TYPE_BASE, | |||
| PNG_FILTER_TYPE_BASE); | |||
| HeapBlock<uint8> rowData ((size_t) width * 4); | |||
| HeapBlock<uint8> rowData (width * 4); | |||
| png_color_8 sig_bit; | |||
| sig_bit.red = 8; | |||
| @@ -247,7 +247,7 @@ bool CoreGraphicsContext::clipToRectangleListWithoutTest (const RectangleList<in | |||
| return false; | |||
| } | |||
| const size_t numRects = (size_t) clipRegion.getNumRectangles(); | |||
| auto numRects = (size_t) clipRegion.getNumRectangles(); | |||
| HeapBlock<CGRect> rects (numRects); | |||
| int i = 0; | |||
| @@ -558,7 +558,7 @@ void CoreGraphicsContext::drawLine (const Line<float>& line) | |||
| void CoreGraphicsContext::fillRectList (const RectangleList<float>& list) | |||
| { | |||
| HeapBlock<CGRect> rects ((size_t) list.getNumRectangles()); | |||
| HeapBlock<CGRect> rects (list.getNumRectangles()); | |||
| size_t num = 0; | |||
| @@ -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; | |||
| } | |||
| @@ -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 | |||
| @@ -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<unsigned long> data ((size_t) dataSize); | |||
| HeapBlock<unsigned long> data (dataSize); | |||
| int index = 0; | |||
| data[index++] = (unsigned long) newIcon.getWidth(); | |||
| @@ -3492,7 +3492,7 @@ private: | |||
| if (attributeSizeBytes > 0) | |||
| { | |||
| // Get attributes (8 bit flag per character): | |||
| HeapBlock<char> attributes ((size_t) attributeSizeBytes); | |||
| HeapBlock<char> attributes (attributeSizeBytes); | |||
| ImmGetCompositionString (hImc, GCS_COMPATTR, attributes, (DWORD) attributeSizeBytes); | |||
| selectionStart = 0; | |||
| @@ -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); | |||
| } | |||
| @@ -103,8 +103,8 @@ private: | |||
| static void verticalRowFlip (PixelARGB* const data, const int w, const int h) | |||
| { | |||
| HeapBlock<PixelARGB> tempRow ((size_t) w); | |||
| const size_t rowSize = sizeof (PixelARGB) * (size_t) w; | |||
| HeapBlock<PixelARGB> 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<PixelARGB> invertedCopy ((size_t) (area.getWidth() * area.getHeight())); | |||
| const size_t rowSize = sizeof (PixelARGB) * (size_t) area.getWidth(); | |||
| HeapBlock<PixelARGB> 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, | |||
| @@ -107,12 +107,12 @@ struct Flipper | |||
| static void flip (HeapBlock<PixelARGB>& 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]); | |||