From 4e1f451520975868659f4c00d00883f5f1cd5805 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 18 Dec 2008 19:31:00 +0000 Subject: Remove unnecessary 0 checks before delete; see http://www.parashift.com/c++-faq-lite/freestore-mgmt.html#faq-16.8 Apologies for the big commit. git-svn-id: svn://localhost/ardour2/branches/3.0@4332 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/audio_diskstream.cc | 36 ++++++++-------------- libs/ardour/audio_port.cc | 6 ++-- libs/ardour/audioanalyser.cc | 4 +-- libs/ardour/audiosource.cc | 22 ++++--------- libs/ardour/base_audio_port.cc | 2 +- libs/ardour/base_midi_port.cc | 2 +- libs/ardour/crossfade.cc | 12 +++----- libs/ardour/export_channel.cc | 9 ++---- libs/ardour/export_preset.cc | 4 +-- libs/ardour/export_utilities.cc | 22 ++++++------- libs/ardour/ladspa_plugin.cc | 9 ++---- libs/ardour/location_importer.cc | 8 ++--- libs/ardour/lv2_plugin.cc | 9 ++---- libs/ardour/midi_port.cc | 6 ++-- libs/ardour/rb_effect.cc | 4 +-- libs/ardour/region.cc | 6 ++-- libs/ardour/reverse.cc | 4 +-- libs/ardour/route.cc | 11 ++----- libs/ardour/session.cc | 4 +-- libs/ardour/session_click.cc | 4 +-- libs/ardour/session_state.cc | 6 ++-- libs/ardour/session_transport.cc | 6 ++-- libs/ardour/sndfilesource.cc | 18 +++-------- libs/ardour/st_stretch.cc | 9 ++---- libs/pbd/pool.cc | 4 +-- libs/pbd/stateful.cc | 4 +-- libs/pbd/xml++.cc | 17 ++++------ .../generic_midi/generic_midi_control_protocol.cc | 4 +-- .../mackie/mackie_control_protocol_poll.cc | 6 +--- 29 files changed, 80 insertions(+), 178 deletions(-) (limited to 'libs') diff --git a/libs/ardour/audio_diskstream.cc b/libs/ardour/audio_diskstream.cc index 4cf834b5c1..8ba1825759 100644 --- a/libs/ardour/audio_diskstream.cc +++ b/libs/ardour/audio_diskstream.cc @@ -2470,33 +2470,21 @@ AudioDiskstream::ChannelInfo::~ChannelInfo () write_source.reset (); } - if (speed_buffer) { - delete [] speed_buffer; - speed_buffer = 0; - } + delete [] speed_buffer; + speed_buffer = 0; - if (playback_wrap_buffer) { - delete [] playback_wrap_buffer; - playback_wrap_buffer = 0; - } + delete [] playback_wrap_buffer; + playback_wrap_buffer = 0; - if (capture_wrap_buffer) { - delete [] capture_wrap_buffer; - capture_wrap_buffer = 0; - } + delete [] capture_wrap_buffer; + capture_wrap_buffer = 0; - if (playback_buf) { - delete playback_buf; - playback_buf = 0; - } + delete playback_buf; + playback_buf = 0; - if (capture_buf) { - delete capture_buf; - capture_buf = 0; - } + delete capture_buf; + capture_buf = 0; - if (capture_transition_buf) { - delete capture_transition_buf; - capture_transition_buf = 0; - } + delete capture_transition_buf; + capture_transition_buf = 0; } diff --git a/libs/ardour/audio_port.cc b/libs/ardour/audio_port.cc index 0e37313d01..7e57a734b8 100644 --- a/libs/ardour/audio_port.cc +++ b/libs/ardour/audio_port.cc @@ -68,10 +68,8 @@ AudioPort::AudioPort (const std::string& name, Flags flags, bool external, nfram AudioPort::~AudioPort() { - if (_ext_port) { - delete _ext_port; - _ext_port = 0; - } + delete _ext_port; + _ext_port = 0; } void diff --git a/libs/ardour/audioanalyser.cc b/libs/ardour/audioanalyser.cc index ab3691d8d1..dcbd2847fe 100644 --- a/libs/ardour/audioanalyser.cc +++ b/libs/ardour/audioanalyser.cc @@ -159,9 +159,7 @@ AudioAnalyser::analyse (const string& path, Readable* src, uint32_t channel) g_rename (tmp_path.c_str(), path.c_str()); } - if (data) { - delete [] data; - } + delete [] data; return ret; } diff --git a/libs/ardour/audiosource.cc b/libs/ardour/audiosource.cc index 8e68b31587..b8366e0ac0 100644 --- a/libs/ardour/audiosource.cc +++ b/libs/ardour/audiosource.cc @@ -97,9 +97,7 @@ AudioSource::~AudioSource () ::close (peakfile); } - if (peak_leftovers) { - delete [] peak_leftovers; - } + delete [] peak_leftovers; } XMLNode& @@ -573,13 +571,8 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, nframes_t npeaks, nframes_t s close (_peakfile); } - if (staging) { - delete [] staging; - } - - if (raw_staging) { - delete [] raw_staging; - } + delete [] staging; + delete [] raw_staging; #ifdef DEBUG_READ_PEAKS cerr << "RP DONE\n"; @@ -656,9 +649,7 @@ AudioSource::build_peaks_from_scratch () unlink (peakpath.c_str()); } - if (buf) { - delete [] buf; - } + delete [] buf; return ret; } @@ -862,9 +853,8 @@ AudioSource::compute_and_write_peaks (Sample* buf, nframes_t first_frame, nframe out: delete [] peakbuf; - if (buf2) { - delete [] buf2; - } + delete [] buf2; + return ret; } diff --git a/libs/ardour/base_audio_port.cc b/libs/ardour/base_audio_port.cc index 0675a4c992..7110102db3 100644 --- a/libs/ardour/base_audio_port.cc +++ b/libs/ardour/base_audio_port.cc @@ -39,7 +39,7 @@ BaseAudioPort::BaseAudioPort (const std::string& name, Flags flgs) BaseAudioPort::~BaseAudioPort () { - if (_own_buffer && _buffer) { + if (_own_buffer) { delete _buffer; } } diff --git a/libs/ardour/base_midi_port.cc b/libs/ardour/base_midi_port.cc index d679c7c04f..0ba4b7c7b2 100644 --- a/libs/ardour/base_midi_port.cc +++ b/libs/ardour/base_midi_port.cc @@ -36,7 +36,7 @@ BaseMidiPort::BaseMidiPort (const std::string& name, Flags flags) BaseMidiPort::~BaseMidiPort() { - if (_own_buffer && _buffer) { + if (_own_buffer) { delete _buffer; } } diff --git a/libs/ardour/crossfade.cc b/libs/ardour/crossfade.cc index 3a7b525db6..70790787c3 100644 --- a/libs/ardour/crossfade.cc +++ b/libs/ardour/crossfade.cc @@ -51,15 +51,11 @@ Sample* Crossfade::crossfade_buffer_in = 0; void Crossfade::set_buffer_size (nframes_t sz) { - if (crossfade_buffer_out) { - delete [] crossfade_buffer_out; - crossfade_buffer_out = 0; - } + delete [] crossfade_buffer_out; + crossfade_buffer_out = 0; - if (crossfade_buffer_in) { - delete [] crossfade_buffer_in; - crossfade_buffer_in = 0; - } + delete [] crossfade_buffer_in; + crossfade_buffer_in = 0; if (sz) { crossfade_buffer_out = new Sample[sz]; diff --git a/libs/ardour/export_channel.cc b/libs/ardour/export_channel.cc index 094d6f9104..865c8fbf3b 100644 --- a/libs/ardour/export_channel.cc +++ b/libs/ardour/export_channel.cc @@ -113,13 +113,8 @@ RegionExportChannelFactory::RegionExportChannelFactory (Session * session, Audio RegionExportChannelFactory::~RegionExportChannelFactory () { - if (mixdown_buffer) { - delete[] mixdown_buffer; - } - - if (gain_buffer) { - delete[] gain_buffer; - } + delete[] mixdown_buffer; + delete[] gain_buffer; } ExportChannelPtr diff --git a/libs/ardour/export_preset.cc b/libs/ardour/export_preset.cc index 1c19cae513..69c5775d12 100644 --- a/libs/ardour/export_preset.cc +++ b/libs/ardour/export_preset.cc @@ -47,9 +47,7 @@ ExportPreset::ExportPreset (string filename, Session & s) : ExportPreset::~ExportPreset () { - if (local) { - delete local; - } + delete local; } void diff --git a/libs/ardour/export_utilities.cc b/libs/ardour/export_utilities.cc index aee5fa21ac..a15a110731 100644 --- a/libs/ardour/export_utilities.cc +++ b/libs/ardour/export_utilities.cc @@ -84,9 +84,9 @@ SampleRateConverter::~SampleRateConverter () if (src_state) { src_delete (src_state); } - if (data_out) { - delete [] data_out; - } + + delete [] data_out; + if (leftover_data) { free (leftover_data); } @@ -105,9 +105,8 @@ SampleRateConverter::process (float * data, nframes_t frames) nframes_t out_samples_max = (nframes_t) ceil (frames * src_data.src_ratio * channels); if (data_out_size < out_samples_max) { - if (data_out) { - delete[] data_out; - } + delete[] data_out; + data_out = new float[out_samples_max]; src_data.data_out = data_out; @@ -233,9 +232,8 @@ SampleFormatConverter::~SampleFormatConverter () if (dither) { gdither_free (dither); } - if (data_out) { - delete[] data_out; - } + + delete[] data_out; } template @@ -246,9 +244,9 @@ SampleFormatConverter::process (float * data, nframes_t frames) size_t data_size = channels * frames * sizeof (TOut); if (data_size > data_out_size) { - if (data_out) { - delete[] data_out; - } + + delete[] data_out; + data_out = new TOut[data_size]; data_out_size = data_size; } diff --git a/libs/ardour/ladspa_plugin.cc b/libs/ardour/ladspa_plugin.cc index 66c6be871b..07bb5ceada 100644 --- a/libs/ardour/ladspa_plugin.cc +++ b/libs/ardour/ladspa_plugin.cc @@ -149,13 +149,8 @@ LadspaPlugin::~LadspaPlugin () // dlclose (module); - if (_control_data) { - delete [] _control_data; - } - - if (_shadow_data) { - delete [] _shadow_data; - } + delete [] _control_data; + delete [] _shadow_data; } string diff --git a/libs/ardour/location_importer.cc b/libs/ardour/location_importer.cc index f321c1d2cb..58a6e72f16 100644 --- a/libs/ardour/location_importer.cc +++ b/libs/ardour/location_importer.cc @@ -95,7 +95,7 @@ LocationImporter::LocationImporter (XMLTree const & source, Session & session, L LocationImporter::~LocationImporter () { - if (!queued() && location) { + if (!queued()) { delete location; } } @@ -178,10 +178,8 @@ LocationImporter::_prepare_move () void LocationImporter::_cancel_move () { - if (location) { - delete location; - location = 0; - } + delete location; + location = 0; } void diff --git a/libs/ardour/lv2_plugin.cc b/libs/ardour/lv2_plugin.cc index 3b0a61b4f0..4d6938fc01 100644 --- a/libs/ardour/lv2_plugin.cc +++ b/libs/ardour/lv2_plugin.cc @@ -165,13 +165,8 @@ LV2Plugin::~LV2Plugin () slv2_value_free(_name); slv2_value_free(_author); - if (_control_data) { - delete [] _control_data; - } - - if (_shadow_data) { - delete [] _shadow_data; - } + delete [] _control_data; + delete [] _shadow_data; } string diff --git a/libs/ardour/midi_port.cc b/libs/ardour/midi_port.cc index 779d317247..93ea3b7c60 100644 --- a/libs/ardour/midi_port.cc +++ b/libs/ardour/midi_port.cc @@ -52,10 +52,8 @@ MidiPort::MidiPort (const std::string& name, Flags flags, bool external, nframes MidiPort::~MidiPort() { - if (_ext_port) { - delete _ext_port; - _ext_port = 0; - } + delete _ext_port; + _ext_port = 0; } void diff --git a/libs/ardour/rb_effect.cc b/libs/ardour/rb_effect.cc index a1dce0497f..063821e896 100644 --- a/libs/ardour/rb_effect.cc +++ b/libs/ardour/rb_effect.cc @@ -358,9 +358,7 @@ RBEffect::run (boost::shared_ptr r) out: - if (gain_buffer) { - delete [] gain_buffer; - } + delete [] gain_buffer; if (buffers) { for (uint32_t i = 0; i < channels; ++i) { diff --git a/libs/ardour/region.cc b/libs/ardour/region.cc index 6375527664..da3564552a 100644 --- a/libs/ardour/region.cc +++ b/libs/ardour/region.cc @@ -1338,10 +1338,8 @@ Region::set_live_state (const XMLNode& node, Change& what_changed, bool send) /* note: derived classes set flags */ - if (_extra_xml) { - delete _extra_xml; - _extra_xml = 0; - } + delete _extra_xml; + _extra_xml = 0; for (XMLNodeConstIterator niter = nlist.begin(); niter != nlist.end(); ++niter) { diff --git a/libs/ardour/reverse.cc b/libs/ardour/reverse.cc index 9c15b1e4d9..6d838bf912 100644 --- a/libs/ardour/reverse.cc +++ b/libs/ardour/reverse.cc @@ -116,9 +116,7 @@ Reverse::run (boost::shared_ptr r) out: - if (buf) { - delete [] buf; - } + delete [] buf; if (ret) { for (si = nsrcs.begin(); si != nsrcs.end(); ++si) { diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index 4b96dc8a93..26dde851c6 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -2274,10 +2274,7 @@ Route::_set_state (const XMLNode& node, bool call_base) nlist = node.children(); - if (deferred_state) { - delete deferred_state; - } - + delete deferred_state; deferred_state = new XMLNode(X_("deferred state")); /* set parent class properties before anything else */ @@ -2521,10 +2518,8 @@ Route::set_control_outs (const vector& ports) vector::const_iterator i; size_t limit; - if (_control_outs) { - delete _control_outs; - _control_outs = 0; - } + delete _control_outs; + _control_outs = 0; if (is_control() || is_master()) { /* no control outs for these two special busses */ diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 875b317936..8efef136d1 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -1336,9 +1336,7 @@ Session::set_block_size (nframes_t nframes) ensure_buffers(_scratch_buffers->available()); - if (_gain_automation_buffer) { - delete [] _gain_automation_buffer; - } + delete [] _gain_automation_buffer; _gain_automation_buffer = new gain_t[nframes]; allocate_pan_automation_buffers (nframes, _npan_buffers, true); diff --git a/libs/ardour/session_click.cc b/libs/ardour/session_click.cc index 7161de6d78..fcbf1e1b03 100644 --- a/libs/ardour/session_click.cc +++ b/libs/ardour/session_click.cc @@ -139,7 +139,7 @@ Session::setup_click_sounds (int which) if ((which == 0 || which == 1)) { - if (click_data && click_data != default_click) { + if (click_data != default_click) { delete [] click_data; click_data = 0; } @@ -178,7 +178,7 @@ Session::setup_click_sounds (int which) if ((which == 0 || which == -1)) { - if (click_emphasis_data && click_emphasis_data != default_click_emphasis) { + if (click_emphasis_data != default_click_emphasis) { delete [] click_emphasis_data; click_emphasis_data = 0; } diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index cb4a9e5813..560143db97 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -768,10 +768,8 @@ Session::restore_state (string snapshot_name) int Session::load_state (string snapshot_name) { - if (state_tree) { - delete state_tree; - state_tree = 0; - } + delete state_tree; + state_tree = 0; state_was_pending = false; diff --git a/libs/ardour/session_transport.cc b/libs/ardour/session_transport.cc index 5612429d0d..c863051461 100644 --- a/libs/ardour/session_transport.cc +++ b/libs/ardour/session_transport.cc @@ -1062,10 +1062,8 @@ Session::set_slave_source (SlaveSource src) // return; // } - if (_slave) { - delete _slave; - _slave = 0; - } + delete _slave; + _slave = 0; if (_transport_speed < 0.0) { reverse = true; diff --git a/libs/ardour/sndfilesource.cc b/libs/ardour/sndfilesource.cc index 6a4b5e325d..b35d36a713 100644 --- a/libs/ardour/sndfilesource.cc +++ b/libs/ardour/sndfilesource.cc @@ -259,13 +259,8 @@ SndFileSource::~SndFileSource () touch_peakfile (); } - if (_broadcast_info) { - delete _broadcast_info; - } - - if (xfade_buf) { - delete [] xfade_buf; - } + delete _broadcast_info; + delete [] xfade_buf; } float @@ -782,13 +777,8 @@ SndFileSource::setup_standard_crossfades (nframes_t rate) xfade_frames = (nframes_t) floor ((Config->get_destructive_xfade_msecs () / 1000.0) * rate); - if (out_coefficient) { - delete [] out_coefficient; - } - - if (in_coefficient) { - delete [] in_coefficient; - } + delete [] out_coefficient; + delete [] in_coefficient; out_coefficient = new gain_t[xfade_frames]; in_coefficient = new gain_t[xfade_frames]; diff --git a/libs/ardour/st_stretch.cc b/libs/ardour/st_stretch.cc index e96cd79f2d..36af40e929 100644 --- a/libs/ardour/st_stretch.cc +++ b/libs/ardour/st_stretch.cc @@ -195,13 +195,8 @@ Stretch::run (boost::shared_ptr a_region) out: - if (gain_buffer) { - delete [] gain_buffer; - } - - if (buffer) { - delete [] buffer; - } + delete [] gain_buffer; + delete [] buffer; if (ret || tsr.cancel) { for (SourceList::iterator si = nsrcs.begin(); si != nsrcs.end(); ++si) { diff --git a/libs/pbd/pool.cc b/libs/pbd/pool.cc index 46de65153e..6d41f14f7e 100644 --- a/libs/pbd/pool.cc +++ b/libs/pbd/pool.cc @@ -91,7 +91,7 @@ MultiAllocSingleReleasePool::MultiAllocSingleReleasePool (string n, unsigned lon MultiAllocSingleReleasePool::~MultiAllocSingleReleasePool () { - if(m_lock) delete m_lock; + delete m_lock; } SingleAllocMultiReleasePool::SingleAllocMultiReleasePool (string n, unsigned long isize, unsigned long nitems) @@ -102,7 +102,7 @@ SingleAllocMultiReleasePool::SingleAllocMultiReleasePool (string n, unsigned lon SingleAllocMultiReleasePool::~SingleAllocMultiReleasePool () { - if(m_lock) delete m_lock; + delete m_lock; } void* diff --git a/libs/pbd/stateful.cc b/libs/pbd/stateful.cc index da014d738f..a7cd3bdb23 100644 --- a/libs/pbd/stateful.cc +++ b/libs/pbd/stateful.cc @@ -40,9 +40,7 @@ Stateful::~Stateful () // Do not delete _extra_xml. The use of add_child_nocopy() // means it needs to live on indefinately. - if (_instant_xml) { - delete _instant_xml; - } + delete _instant_xml; } void diff --git a/libs/pbd/xml++.cc b/libs/pbd/xml++.cc index a42923132b..7d406d6c30 100644 --- a/libs/pbd/xml++.cc +++ b/libs/pbd/xml++.cc @@ -39,9 +39,7 @@ XMLTree::XMLTree(const XMLTree * from) XMLTree::~XMLTree() { - if (_root) { - delete _root; - } + delete _root; } int @@ -63,10 +61,9 @@ XMLTree::read_internal(bool validate) { //shouldnt be used anywhere ATM, remove if so! assert(!validate); - if (_root) { - delete _root; - _root = 0; - } + + delete _root; + _root = 0; xmlParserCtxtPtr ctxt; /* the parser context */ xmlDocPtr doc; /* the resulting document tree */ @@ -119,10 +116,8 @@ XMLTree::read_buffer(const string & buffer) _filename = ""; - if (_root) { - delete _root; - _root = 0; - } + delete _root; + _root = 0; doc = xmlParseMemory((char *) buffer.c_str(), buffer.length()); if (!doc) { diff --git a/libs/surfaces/generic_midi/generic_midi_control_protocol.cc b/libs/surfaces/generic_midi/generic_midi_control_protocol.cc index cd8c724e75..9f6441eb4b 100644 --- a/libs/surfaces/generic_midi/generic_midi_control_protocol.cc +++ b/libs/surfaces/generic_midi/generic_midi_control_protocol.cc @@ -232,9 +232,7 @@ GenericMidiControlProtocol::stop_learning (Controllable* c) } } - if (dptr) { - delete dptr; - } + delete dptr; } void diff --git a/libs/surfaces/mackie/mackie_control_protocol_poll.cc b/libs/surfaces/mackie/mackie_control_protocol_poll.cc index 88c00ed6eb..2bf992f1b7 100644 --- a/libs/surfaces/mackie/mackie_control_protocol_poll.cc +++ b/libs/surfaces/mackie/mackie_control_protocol_poll.cc @@ -93,11 +93,7 @@ void MackieControlProtocol::update_ports() if ( _ports_changed ) { // create new pollfd structures - if ( pfd != 0 ) - { - delete[] pfd; - pfd = 0; - } + delete[] pfd; pfd = new pollfd[_ports.size()]; #ifdef DEBUG cout << "pfd: " << pfd << endl; -- cgit v1.2.3