Fix Memory-management issues from TODO.md
- JaySynth's destructor now uses delete[] to match every new T[n] allocation (m_pVoices, pPer_voice_controls, pCurrNoteInfos, humanize_voice_param[i], ppHumanizedSliders[i], m_ppAudioThread, m_ppEventAudioThreadRdy), fixing undefined behavior from the mismatched scalar delete. - Found and fixed the same new[]/delete mismatch pattern via ScopedPointer in PluginProcessor.cpp: ScopedPointer always calls scalar delete (per JUCE's own doc comment "do not give it an array to hold!"), so ScopedPointer<char> holding a new char[...] in setStateInformation/setCurrentProgramStateInformation had the same bug. Replaced both with HeapBlock<char>, JUCE's array-owning, malloc/free-backed smart pointer. - Added a shared SynthCheckAlloc() helper (synth_defs.h/synth_debug.c) that aborts with a diagnostic instead of returning NULL, and wrapped all 24 malloc call sites across the C DSP core (env.c, lfo.c, vcf.c, vco.c, blit.c, wavetable.c, voice.c, param_scale.c). All are one-time init/bufsize-change calls, never in the per-block render path, so this adds no real-time-thread overhead. Verified with clean debug and release builds (no new warnings/errors) and a full link. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011dhtwRLARk4eiPngcQykLJ
This commit is contained in:
@@ -158,7 +158,7 @@ JaySynth::~JaySynth()
|
||||
{
|
||||
delete(m_ppAudioThread[i]);
|
||||
}
|
||||
delete(m_ppAudioThread);
|
||||
delete[] m_ppAudioThread;
|
||||
|
||||
SynthDebug("delete params\n");
|
||||
paramInfoFree(&pb_range[0]);
|
||||
@@ -171,25 +171,25 @@ JaySynth::~JaySynth()
|
||||
{
|
||||
paramInfoFree(&humanize_voice_param[i][j]);
|
||||
}
|
||||
delete (humanize_voice_param[i]);
|
||||
delete (ppHumanizedSliders[i]);
|
||||
delete[] humanize_voice_param[i];
|
||||
delete[] ppHumanizedSliders[i];
|
||||
}
|
||||
delete (humanize_voice_param);
|
||||
delete (ppHumanizedSliders);
|
||||
delete[] humanize_voice_param;
|
||||
delete[] ppHumanizedSliders;
|
||||
|
||||
for (i = max_num_voices; --i >= 0;)
|
||||
{
|
||||
removeVoice(i);
|
||||
}
|
||||
|
||||
delete (pPer_voice_controls);
|
||||
delete (pCurrNoteInfos);
|
||||
delete (m_pVoices);
|
||||
delete[] pPer_voice_controls;
|
||||
delete[] pCurrNoteInfos;
|
||||
delete[] m_pVoices;
|
||||
for (i=0; i < m_num_audiothreads; i++)
|
||||
{
|
||||
delete (m_ppEventAudioThreadRdy[i]);
|
||||
}
|
||||
delete(m_ppEventAudioThreadRdy);
|
||||
delete[] m_ppEventAudioThreadRdy;
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user