1
0
Fork 0

Better c++ design to avoid leaks in case of exceptions

This commit is contained in:
Frederic Bouvier 2011-12-17 18:13:05 +01:00
parent e6e09a8161
commit 54d5614e52

View file

@ -29,6 +29,7 @@
#include "radio.hxx"
#include <simgear/scene/material/mat.hxx>
#include <Scenery/scenery.hxx>
#include <boost/scoped_array.hpp>
#define WITH_POINT_TO_POINT 1
#include "itm.cpp"
@ -382,8 +383,7 @@ double FGRadioTransmission::ITM_calculate_attenuation(SGGeod pos, double freq, i
elevations.push_front(num_points -1);
int size = elevations.size();
double *itm_elev;
itm_elev = new double[size];
boost::scoped_array<double> itm_elev( new double[size] );
for(int i=0;i<size;i++) {
itm_elev[i]=elevations[i];
@ -391,18 +391,18 @@ double FGRadioTransmission::ITM_calculate_attenuation(SGGeod pos, double freq, i
if((transmission_type == 3) || (transmission_type == 4)) {
// the sender and receiver roles are switched
ITM::point_to_point(itm_elev, receiver_height, transmitter_height,
ITM::point_to_point(itm_elev.get(), receiver_height, transmitter_height,
eps_dielect, sgm_conductivity, eno, frq_mhz, radio_climate,
pol, conf, rel, dbloss, strmode, p_mode, horizons, errnum);
if( _root_node->getBoolValue( "use-clutter-attenuation", false ) )
calculate_clutter_loss(frq_mhz, itm_elev, materials, receiver_height, transmitter_height, p_mode, horizons, clutter_loss);
calculate_clutter_loss(frq_mhz, itm_elev.get(), materials, receiver_height, transmitter_height, p_mode, horizons, clutter_loss);
}
else {
ITM::point_to_point(itm_elev, transmitter_height, receiver_height,
ITM::point_to_point(itm_elev.get(), transmitter_height, receiver_height,
eps_dielect, sgm_conductivity, eno, frq_mhz, radio_climate,
pol, conf, rel, dbloss, strmode, p_mode, horizons, errnum);
if( _root_node->getBoolValue( "use-clutter-attenuation", false ) )
calculate_clutter_loss(frq_mhz, itm_elev, materials, transmitter_height, receiver_height, p_mode, horizons, clutter_loss);
calculate_clutter_loss(frq_mhz, itm_elev.get(), materials, transmitter_height, receiver_height, p_mode, horizons, clutter_loss);
}
double pol_loss = 0.0;
@ -457,7 +457,6 @@ double FGRadioTransmission::ITM_calculate_attenuation(SGGeod pos, double freq, i
//_root_node->setDoubleValue("station[0]/tx-pattern-gain", tx_pattern_gain);
//_root_node->setDoubleValue("station[0]/rx-pattern-gain", rx_pattern_gain);
delete[] itm_elev;
for (unsigned i =0; i < materials.size(); i++) {
delete materials[i];
}