Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename malloc to jmalloc etc #1337

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace juce::build_tools

const int bufferSize = 4096;
HeapBlock<uint8> buffer;
buffer.malloc (bufferSize);
buffer.jmalloc (bufferSize);

for (;;)
{
Expand Down
6 changes: 3 additions & 3 deletions modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ class AudioBuffer
if (allocatedBytes != 0)
{
allocatedBytes = 0;
allocatedData.free();
allocatedData.jfree();
}

numChannels = newNumChannels;
Expand Down Expand Up @@ -1200,7 +1200,7 @@ class AudioBuffer
channelListSize += requiredSampleAlignment - alignmentOverflow;

allocatedBytes = (size_t) numChannels * (size_t) size * sizeof (Type) + channelListSize + 32;
allocatedData.malloc (allocatedBytes);
allocatedData.jmalloc (allocatedBytes);
channels = unalignedPointerCast<Type**> (allocatedData.get());
auto chan = unalignedPointerCast<Type*> (allocatedData + channelListSize);

Expand All @@ -1225,7 +1225,7 @@ class AudioBuffer
}
else
{
allocatedData.malloc (numChannels + 1, sizeof (Type*));
allocatedData.jmalloc (numChannels + 1, sizeof (Type*));
channels = unalignedPointerCast<Type**> (allocatedData.get());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ void ResamplingAudioSource::prepareToPlay (int samplesPerBlockExpected, double s

buffer.setSize (numChannels, scaledBlockSize + 32);

filterStates.calloc (numChannels);
srcBuffers.calloc (numChannels);
destBuffers.calloc (numChannels);
filterStates.jcalloc (numChannels);
srcBuffers.jcalloc (numChannels);
destBuffers.jcalloc (numChannels);
createLowPass (ratio);

flushBuffers();
Expand Down
4 changes: 2 additions & 2 deletions modules/juce_audio_basics/utilities/juce_Reverb.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ class Reverb
if (size != bufferSize)
{
bufferIndex = 0;
buffer.malloc (size);
buffer.jmalloc (size);
bufferSize = size;
}

Expand Down Expand Up @@ -272,7 +272,7 @@ class Reverb
if (size != bufferSize)
{
bufferIndex = 0;
buffer.malloc (size);
buffer.jmalloc (size);
bufferSize = size;
}

Expand Down
20 changes: 10 additions & 10 deletions modules/juce_audio_devices/native/juce_ASIO_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,8 @@ class ASIOAudioIODevice final : public AudioIODevice,
::CoInitialize (nullptr);

name = devName;
inBuffers.calloc (4);
outBuffers.calloc (4);
inBuffers.jcalloc (4);
outBuffers.jcalloc (4);

jassert (currentASIODev[slotNumber] == nullptr);
currentASIODev[slotNumber] = this;
Expand Down Expand Up @@ -443,8 +443,8 @@ class ASIOAudioIODevice final : public AudioIODevice,
if (asioObject->future (kAsioCanReportOverload, nullptr) != ASE_OK)
xruns = -1;

inBuffers.calloc (totalNumInputChans + 8);
outBuffers.calloc (totalNumOutputChans + 8);
inBuffers.jcalloc (totalNumInputChans + 8);
outBuffers.jcalloc (totalNumOutputChans + 8);

if (needToReset)
{
Expand Down Expand Up @@ -486,7 +486,7 @@ class ASIOAudioIODevice final : public AudioIODevice,
if (err == ASE_OK)
{
buffersCreated = true;
ioBufferSpace.calloc (totalBuffers * currentBlockSizeSamples + 32);
ioBufferSpace.jcalloc (totalBuffers * currentBlockSizeSamples + 32);

int n = 0;
Array<int> types;
Expand Down Expand Up @@ -1211,11 +1211,11 @@ class ASIOAudioIODevice final : public AudioIODevice,
JUCE_ASIO_LOG (String ((int) totalNumInputChans) + " in, " + String ((int) totalNumOutputChans) + " out");

const int chansToAllocate = totalNumInputChans + totalNumOutputChans + 4;
bufferInfos.calloc (chansToAllocate);
inBuffers.calloc (chansToAllocate);
outBuffers.calloc (chansToAllocate);
inputFormat.calloc (chansToAllocate);
outputFormat.calloc (chansToAllocate);
bufferInfos.jcalloc (chansToAllocate);
inBuffers.jcalloc (chansToAllocate);
outBuffers.jcalloc (chansToAllocate);
inputFormat.jcalloc (chansToAllocate);
outputFormat.jcalloc (chansToAllocate);

if ((err = refreshBufferSizes()) == 0)
{
Expand Down
8 changes: 4 additions & 4 deletions modules/juce_audio_devices/native/juce_Bela_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ class BelaAudioIODevice final : public AudioIODevice
actualNumberOfInputs = jmin (numIns, actualNumberOfInputs);
actualNumberOfOutputs = jmin (numOuts, actualNumberOfOutputs);

channelInBuffer.calloc (actualNumberOfInputs);
channelOutBuffer.calloc (actualNumberOfOutputs);
channelInBuffer.jcalloc (actualNumberOfInputs);
channelOutBuffer.jcalloc (actualNumberOfOutputs);

return {};
}
Expand All @@ -297,8 +297,8 @@ class BelaAudioIODevice final : public AudioIODevice
actualNumberOfInputs = 0;
actualNumberOfOutputs = 0;

channelInBuffer.free();
channelOutBuffer.free();
channelInBuffer.jfree();
channelOutBuffer.jfree();
}
}

Expand Down
4 changes: 2 additions & 2 deletions modules/juce_audio_devices/native/juce_CoreAudio_mac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ class CoreAudioInternal final : private Timer,
auto streams = getStreams();
const auto total = std::accumulate (streams.begin(), streams.end(), 0,
[] (int n, const auto& s) { return n + (s != nullptr ? s->channels : 0); });
audioBuffer.calloc (total * tempBufSize);
audioBuffer.jcalloc (total * tempBufSize);

auto channels = 0;
for (auto* stream : streams)
Expand Down Expand Up @@ -868,7 +868,7 @@ class CoreAudioInternal final : private Timer,

int allocateTempBuffers (int tempBufSize, int channelCount, HeapBlock<float>& buffer)
{
tempBuffers.calloc (channels + 2);
tempBuffers.jcalloc (channels + 2);

for (int i = 0; i < channels; ++i)
tempBuffers[i] = buffer + channelCount++ * tempBufSize;
Expand Down
4 changes: 2 additions & 2 deletions modules/juce_audio_devices/native/juce_CoreMidi_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ void oldSendImpl (MIDIPortRef port, MIDIEndpointRef endpoint, const ump::Bytestr
const int maxPacketSize = 256;
int pos = 0, bytesLeft = (int) dataSize;
const int numPackets = (bytesLeft + maxPacketSize - 1) / maxPacketSize;
allocatedPackets.malloc ((size_t) (32 * (size_t) numPackets + dataSize), 1);
allocatedPackets.jmalloc ((size_t) (32 * (size_t) numPackets + dataSize), 1);
packetToSend = allocatedPackets;
packetToSend->numPackets = (UInt32) numPackets;

Expand All @@ -228,7 +228,7 @@ void oldSendImpl (MIDIPortRef port, MIDIEndpointRef endpoint, const ump::Bytestr

if (dataSize > stackCapacity)
{
allocatedPackets.malloc ((sizeof (MIDIPacketList) - stackCapacity) + dataSize, 1);
allocatedPackets.jmalloc ((sizeof (MIDIPacketList) - stackCapacity) + dataSize, 1);
packetToSend = allocatedPackets;
}

Expand Down
4 changes: 2 additions & 2 deletions modules/juce_audio_devices/native/juce_JackAudio_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ class JackAudioIODevice final : public AudioIODevice
JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0));
}

inChans.calloc (totalNumberOfInputChannels + 2);
outChans.calloc (totalNumberOfOutputChannels + 2);
inChans.jcalloc (totalNumberOfInputChannels + 2);
outChans.jcalloc (totalNumberOfOutputChannels + 2);
}
}

Expand Down
2 changes: 1 addition & 1 deletion modules/juce_audio_formats/codecs/juce_AiffAudioFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ class AiffAudioFormatReader final : public AudioFormatReader
else if (type == chunkName ("INST"))
{
HeapBlock<InstChunk> inst;
inst.calloc (jmax ((size_t) length + 1, sizeof (InstChunk)), 1);
inst.jcalloc (jmax ((size_t) length + 1, sizeof (InstChunk)), 1);
input->read (inst, (int) length);
inst->copyTo (metadataValuesMap);
}
Expand Down
6 changes: 3 additions & 3 deletions modules/juce_audio_formats/codecs/juce_CoreAudioFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ class CoreAudioReader final : public AudioFormatReader

if (status == noErr && sizeOfLayout >= (sizeof (AudioChannelLayout) - sizeof (AudioChannelDescription)))
{
caLayout.malloc (1, static_cast<size_t> (sizeOfLayout));
caLayout.jmalloc (1, static_cast<size_t> (sizeOfLayout));

status = AudioFileGetProperty (audioFileID, kAudioFilePropertyChannelLayout,
&sizeOfLayout, caLayout.get());
Expand Down Expand Up @@ -467,9 +467,9 @@ class CoreAudioReader final : public AudioFormatReader
&destinationAudioFormat);
if (status == noErr)
{
bufferList.malloc (1, sizeof (AudioBufferList) + numChannels * sizeof (::AudioBuffer));
bufferList.jmalloc (1, sizeof (AudioBufferList) + numChannels * sizeof (::AudioBuffer));
bufferList->mNumberBuffers = numChannels;
channelMap.malloc (numChannels);
channelMap.jmalloc (numChannels);

if (hasLayout && caLayout != nullptr)
{
Expand Down
4 changes: 2 additions & 2 deletions modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,8 +440,8 @@ class FlacWriter final : public AudioFormatWriter

if (bitsToShift > 0)
{
temp.malloc (numChannels * (size_t) numSamples);
channels.calloc (numChannels + 1);
temp.jmalloc (numChannels * (size_t) numSamples);
channels.jcalloc (numChannels + 1);

for (unsigned int i = 0; i < numChannels; ++i)
{
Expand Down
8 changes: 4 additions & 4 deletions modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1348,28 +1348,28 @@ class WavAudioFormatReader final : public AudioFormatReader
bwavSize = length;

HeapBlock<BWAVChunk> bwav;
bwav.calloc (jmax ((size_t) length + 1, sizeof (BWAVChunk)), 1);
bwav.jcalloc (jmax ((size_t) length + 1, sizeof (BWAVChunk)), 1);
input->read (bwav, (int) length);
bwav->copyTo (dict, (int) length);
}
else if (chunkType == chunkName ("smpl"))
{
HeapBlock<SMPLChunk> smpl;
smpl.calloc (jmax ((size_t) length + 1, sizeof (SMPLChunk)), 1);
smpl.jcalloc (jmax ((size_t) length + 1, sizeof (SMPLChunk)), 1);
input->read (smpl, (int) length);
smpl->copyTo (dict, (int) length);
}
else if (chunkType == chunkName ("inst") || chunkType == chunkName ("INST")) // need to check which...
{
HeapBlock<InstChunk> inst;
inst.calloc (jmax ((size_t) length + 1, sizeof (InstChunk)), 1);
inst.jcalloc (jmax ((size_t) length + 1, sizeof (InstChunk)), 1);
input->read (inst, (int) length);
inst->copyTo (dict);
}
else if (chunkType == chunkName ("cue "))
{
HeapBlock<CueChunk> cue;
cue.calloc (jmax ((size_t) length + 1, sizeof (CueChunk)), 1);
cue.jcalloc (jmax ((size_t) length + 1, sizeof (CueChunk)), 1);
input->read (cue, (int) length);
cue->copyTo (dict, (int) length);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ class WMAudioReader final : public AudioFormatReader
hr = wmMediaProperties->GetMediaType (nullptr, &sizeMediaType);

HeapBlock<WM_MEDIA_TYPE> mediaType;
mediaType.malloc (sizeMediaType, 1);
mediaType.jmalloc (sizeMediaType, 1);
hr = wmMediaProperties->GetMediaType (mediaType, &sizeMediaType);

if (mediaType->majortype == WMMEDIATYPE_Audio)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ ComponentResult Initialize() override
return err;

mapper.alloc (*juceFilter);
pulledSucceeded.calloc (static_cast<size_t> (AudioUnitHelpers::getBusCountForWrapper (*juceFilter, true)));
pulledSucceeded.jcalloc (static_cast<size_t> (AudioUnitHelpers::getBusCountForWrapper (*juceFilter, true)));

prepareToPlay();

Expand All @@ -201,7 +201,7 @@ void Cleanup() override
{
MusicDeviceBase::Cleanup();

pulledSucceeded.free();
pulledSucceeded.jfree();
mapper.release();

if (juceFilter != nullptr)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ void alloc()
+ ((numBuffers - 1) * static_cast<int> (sizeof (::AudioBuffer)));
jassert (bytes > 0);

bufferListStorage.calloc (static_cast<size_t> (bytes));
bufferListStorage.jcalloc (static_cast<size_t> (bytes));
bufferList = reinterpret_cast<AudioBufferList*> (bufferListStorage.getData());

const int bufferChannels = isInterleaved ? numberOfChannels : 1;
Expand All @@ -960,7 +960,7 @@ void alloc()
void dealloc()
{
bufferList = nullptr;
bufferListStorage.free();
bufferListStorage.jfree();
scratchBuffer.setSize (0, 0);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -519,8 +519,8 @@ class JuceVSTWrapper final : public AudioProcessorListener,
isProcessing = true;

auto numInAndOutChannels = static_cast<size_t> (vstEffect.numInputs + vstEffect.numOutputs);
floatTempBuffers .channels.calloc (numInAndOutChannels);
doubleTempBuffers.channels.calloc (numInAndOutChannels);
floatTempBuffers .channels.jcalloc (numInAndOutChannels);
doubleTempBuffers.channels.jcalloc (numInAndOutChannels);

auto currentRate = sampleRate;
auto currentBlockSize = blockSize;
Expand Down Expand Up @@ -574,8 +574,8 @@ class JuceVSTWrapper final : public AudioProcessorListener,
outgoingEvents.freeEvents();

isProcessing = false;
floatTempBuffers.channels.free();
doubleTempBuffers.channels.free();
floatTempBuffers.channels.jfree();
doubleTempBuffers.channels.jfree();

deleteTempChannels();
}
Expand Down Expand Up @@ -1930,8 +1930,8 @@ class JuceVSTWrapper final : public AudioProcessorListener,

const auto speakerBaseSize = offsetof (Vst2::VstSpeakerArrangement, speakers);

cachedInArrangement .malloc (speakerBaseSize + (static_cast<std::size_t> (inputLayout. size()) * sizeof (Vst2::VstSpeakerProperties)), 1);
cachedOutArrangement.malloc (speakerBaseSize + (static_cast<std::size_t> (outputLayout.size()) * sizeof (Vst2::VstSpeakerProperties)), 1);
cachedInArrangement .jmalloc (speakerBaseSize + (static_cast<std::size_t> (inputLayout. size()) * sizeof (Vst2::VstSpeakerProperties)), 1);
cachedOutArrangement.jmalloc (speakerBaseSize + (static_cast<std::size_t> (outputLayout.size()) * sizeof (Vst2::VstSpeakerProperties)), 1);

*pluginInput = cachedInArrangement. getData();
*pluginOutput = cachedOutArrangement.getData();
Expand Down
12 changes: 6 additions & 6 deletions modules/juce_audio_processors/format_types/juce_AU_Shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ struct AudioUnitHelpers
void release()
{
inputLayoutMap = outputLayoutMap = nullptr;
inputLayoutMapPtrStorage.free();
outputLayoutMapPtrStorage.free();
inputLayoutMapStorage.free();
outputLayoutMapStorage.free();
inputLayoutMapPtrStorage.jfree();
outputLayoutMapPtrStorage.jfree();
inputLayoutMapStorage.jfree();
outputLayoutMapStorage.jfree();
}

inline const int* get (bool input, int bus) const noexcept { return (input ? inputLayoutMap : outputLayoutMap)[bus]; }
Expand All @@ -95,8 +95,8 @@ struct AudioUnitHelpers
const int totalInChannels = processor.getTotalNumInputChannels();
const int totalOutChannels = processor.getTotalNumOutputChannels();

layoutMapPtrStorage.calloc (static_cast<size_t> (numBuses));
layoutMapStorage.calloc (static_cast<size_t> (isInput ? totalInChannels : totalOutChannels));
layoutMapPtrStorage.jcalloc (static_cast<size_t> (numBuses));
layoutMapStorage.jcalloc (static_cast<size_t> (isInput ? totalInChannels : totalOutChannels));

layoutMap = layoutMapPtrStorage.get();

Expand Down
Loading