Fixes for new() and exit(). Hints from falkTX - thanks!

pull/2/head
Holger Wirtz 7 years ago
parent 6801e49fca
commit 506f090c80
  1. 44
      src/dexed.cpp

@ -49,33 +49,26 @@ Dexed::Dexed(double rate) : lvtk::Synth<DexedVoice, Dexed>(p_n_ports, p_midi_in)
Env::init_sr(rate); Env::init_sr(rate);
fx.init(rate); fx.init(rate);
if(!(engineMkI=new EngineMkI)) if(!(engineMkI=new (std::nothrow) EngineMkI))
{ {
TRACE("Cannot not create engine EngineMkI"); TRACE("Cannot not create engine EngineMkI");
exit(400);
} }
if(!(engineOpl=new EngineOpl)) if(!(engineOpl=new (std::nothrow) EngineOpl))
{ {
if(engineMkI) delete(engineMkI);
delete(engineMkI);
TRACE("Cannot not create engine EngineOpl"); TRACE("Cannot not create engine EngineOpl");
exit(401);
} }
if(!(engineMsfa=new FmCore)) if(!(engineMsfa=new (std::nothrow) FmCore))
{ {
if(engineMkI) delete(engineMkI);
delete(engineMkI); delete(engineOpl);
if(engineOpl)
delete(engineOpl);
TRACE("Cannot create engine FmCore"); TRACE("Cannot create engine FmCore");
exit(402);
} }
for(i=0; i<MAX_ACTIVE_NOTES; i++) { for(i=0; i<MAX_ACTIVE_NOTES; i++) {
if(!(voices[i].dx7_note = new Dx7Note)) if(!(voices[i].dx7_note = new (std::nothrow) Dx7Note))
{ {
TRACE("Cannot create DX7Note [%d]",i); TRACE("Cannot create DX7Note [%d]",i);
exit(403);
} }
voices[i].keydown = false; voices[i].keydown = false;
voices[i].sustained = false; voices[i].sustained = false;
@ -103,15 +96,11 @@ Dexed::Dexed(double rate) : lvtk::Synth<DexedVoice, Dexed>(p_n_ports, p_midi_in)
bufsize_=256; bufsize_=256;
if(!(outbuf_=new float[bufsize_])) if(!(outbuf_=new (std::nothrow) float[bufsize_]))
{
TRACE("Cannot create outbuf_ buffer"); TRACE("Cannot create outbuf_ buffer");
exit(404);
}
lfo.reset(data+137); lfo.reset(data+137);
setMonoMode(false); setMonoMode(false);
sustain = false; sustain = false;
@ -133,25 +122,16 @@ Dexed::~Dexed()
{ {
TRACE("Hi"); TRACE("Hi");
if(outbuf_) delete [] outbuf_;
delete [] outbuf_;
currentNote = -1; currentNote = -1;
for (uint8_t note = 0; note < MAX_ACTIVE_NOTES; ++note) for (uint8_t note = 0; note < MAX_ACTIVE_NOTES; ++note)
{
if(voices[note].dx7_note)
{
delete voices[note].dx7_note; delete voices[note].dx7_note;
}
}
if(engineMsfa) delete(engineMsfa);
delete(engineMsfa); delete(engineOpl);
if(engineOpl) delete(engineMkI);
delete(engineOpl);
if(engineMkI)
delete(engineMkI);
TRACE("Bye"); TRACE("Bye");
TRACE("--------------------------------------------------------------------------------"); TRACE("--------------------------------------------------------------------------------");

Loading…
Cancel
Save