1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-14 12:10:34 +00:00

Replace raw pointers by smart pointers. Remove delete

This commit is contained in:
Carles Fernandez 2019-06-30 12:51:23 +02:00
parent 2cc06c8b63
commit d72542861f
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
18 changed files with 44 additions and 63 deletions

View File

@ -145,10 +145,10 @@ galileo_e5a_noncoherentIQ_acquisition_caf_cc::galileo_e5a_noncoherentIQ_acquisit
} }
// Direct FFT // Direct FFT
d_fft_if = new gr::fft::fft_complex(d_fft_size, true); d_fft_if = std::make_shared<gr::fft::fft_complex>(d_fft_size, true);
// Inverse FFT // Inverse FFT
d_ifft = new gr::fft::fft_complex(d_fft_size, false); d_ifft = std::make_shared<gr::fft::fft_complex>(d_fft_size, false);
// For dumping samples into a file // For dumping samples into a file
d_dump = dump; d_dump = dump;
@ -210,9 +210,6 @@ galileo_e5a_noncoherentIQ_acquisition_caf_cc::~galileo_e5a_noncoherentIQ_acquisi
} }
} }
delete d_fft_if;
delete d_ifft;
try try
{ {
if (d_dump) if (d_dump)

View File

@ -44,6 +44,7 @@
#include <gnuradio/fft/fft.h> #include <gnuradio/fft/fft.h>
#include <gnuradio/gr_complex.h> #include <gnuradio/gr_complex.h>
#include <fstream> #include <fstream>
#include <memory>
#include <string> #include <string>
#include <utility> #include <utility>
@ -122,8 +123,8 @@ private:
gr_complex* d_fft_code_Q_A; gr_complex* d_fft_code_Q_A;
gr_complex* d_fft_code_Q_B; gr_complex* d_fft_code_Q_B;
gr_complex* d_inbuffer; gr_complex* d_inbuffer;
gr::fft::fft_complex* d_fft_if; std::shared_ptr<gr::fft::fft_complex> d_fft_if;
gr::fft::fft_complex* d_ifft; std::shared_ptr<gr::fft::fft_complex> d_ifft;
Gnss_Synchro* d_gnss_synchro; Gnss_Synchro* d_gnss_synchro;
unsigned int d_code_phase; unsigned int d_code_phase;
float d_doppler_freq; float d_doppler_freq;

View File

@ -87,10 +87,10 @@ galileo_pcps_8ms_acquisition_cc::galileo_pcps_8ms_acquisition_cc(
d_magnitude = static_cast<float *>(volk_gnsssdr_malloc(d_fft_size * sizeof(float), volk_gnsssdr_get_alignment())); d_magnitude = static_cast<float *>(volk_gnsssdr_malloc(d_fft_size * sizeof(float), volk_gnsssdr_get_alignment()));
// Direct FFT // Direct FFT
d_fft_if = new gr::fft::fft_complex(d_fft_size, true); d_fft_if = std::make_shared<gr::fft::fft_complex>(d_fft_size, true);
// Inverse FFT // Inverse FFT
d_ifft = new gr::fft::fft_complex(d_fft_size, false); d_ifft = std::make_shared<gr::fft::fft_complex>(d_fft_size, false);
// For dumping samples into a file // For dumping samples into a file
d_dump = dump; d_dump = dump;
@ -123,9 +123,6 @@ galileo_pcps_8ms_acquisition_cc::~galileo_pcps_8ms_acquisition_cc()
volk_gnsssdr_free(d_fft_code_B); volk_gnsssdr_free(d_fft_code_B);
volk_gnsssdr_free(d_magnitude); volk_gnsssdr_free(d_magnitude);
delete d_ifft;
delete d_fft_if;
try try
{ {
if (d_dump) if (d_dump)

View File

@ -38,6 +38,7 @@
#include <gnuradio/fft/fft.h> #include <gnuradio/fft/fft.h>
#include <gnuradio/gr_complex.h> #include <gnuradio/gr_complex.h>
#include <fstream> #include <fstream>
#include <memory>
#include <string> #include <string>
#include <utility> #include <utility>
@ -105,8 +106,8 @@ private:
uint32_t d_num_doppler_bins; uint32_t d_num_doppler_bins;
gr_complex* d_fft_code_A; gr_complex* d_fft_code_A;
gr_complex* d_fft_code_B; gr_complex* d_fft_code_B;
gr::fft::fft_complex* d_fft_if; std::shared_ptr<gr::fft::fft_complex> d_fft_if;
gr::fft::fft_complex* d_ifft; std::shared_ptr<gr::fft::fft_complex> d_ifft;
Gnss_Synchro* d_gnss_synchro; Gnss_Synchro* d_gnss_synchro;
uint32_t d_code_phase; uint32_t d_code_phase;
float d_doppler_freq; float d_doppler_freq;

View File

@ -140,10 +140,10 @@ pcps_acquisition::pcps_acquisition(const Acq_Conf& conf_) : gr::block("pcps_acqu
d_input_signal = static_cast<gr_complex*>(volk_gnsssdr_malloc(d_fft_size * sizeof(gr_complex), volk_gnsssdr_get_alignment())); d_input_signal = static_cast<gr_complex*>(volk_gnsssdr_malloc(d_fft_size * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
// Direct FFT // Direct FFT
d_fft_if = new gr::fft::fft_complex(d_fft_size, true); d_fft_if = std::make_shared<gr::fft::fft_complex>(d_fft_size, true);
// Inverse FFT // Inverse FFT
d_ifft = new gr::fft::fft_complex(d_fft_size, false); d_ifft = std::make_shared<gr::fft::fft_complex>(d_fft_size, false);
d_gnss_synchro = nullptr; d_gnss_synchro = nullptr;
d_grid_doppler_wipeoffs = nullptr; d_grid_doppler_wipeoffs = nullptr;
@ -237,8 +237,6 @@ pcps_acquisition::~pcps_acquisition()
volk_gnsssdr_free(d_magnitude); volk_gnsssdr_free(d_magnitude);
volk_gnsssdr_free(d_tmp_buffer); volk_gnsssdr_free(d_tmp_buffer);
volk_gnsssdr_free(d_input_signal); volk_gnsssdr_free(d_input_signal);
delete d_ifft;
delete d_fft_if;
volk_gnsssdr_free(d_data_buffer); volk_gnsssdr_free(d_data_buffer);
if (d_cshort) if (d_cshort)
{ {

View File

@ -62,6 +62,7 @@
#include <gnuradio/types.h> // for gr_vector_const_void_star #include <gnuradio/types.h> // for gr_vector_const_void_star
#include <volk/volk_complex.h> // for lv_16sc_t #include <volk/volk_complex.h> // for lv_16sc_t
#include <cstdint> #include <cstdint>
#include <memory>
#include <string> #include <string>
#include <utility> #include <utility>
@ -138,8 +139,8 @@ private:
gr_complex* d_fft_codes; gr_complex* d_fft_codes;
gr_complex* d_data_buffer; gr_complex* d_data_buffer;
lv_16sc_t* d_data_buffer_sc; lv_16sc_t* d_data_buffer_sc;
gr::fft::fft_complex* d_fft_if; std::shared_ptr<gr::fft::fft_complex> d_fft_if;
gr::fft::fft_complex* d_ifft; std::shared_ptr<gr::fft::fft_complex> d_ifft;
Gnss_Synchro* d_gnss_synchro; Gnss_Synchro* d_gnss_synchro;
arma::fmat grid_; arma::fmat grid_;
arma::fmat narrow_grid_; arma::fmat narrow_grid_;

View File

@ -93,10 +93,10 @@ pcps_acquisition_fine_doppler_cc::pcps_acquisition_fine_doppler_cc(const Acq_Con
d_10_ms_buffer = static_cast<gr_complex *>(volk_gnsssdr_malloc(50 * d_samples_per_ms * sizeof(gr_complex), volk_gnsssdr_get_alignment())); d_10_ms_buffer = static_cast<gr_complex *>(volk_gnsssdr_malloc(50 * d_samples_per_ms * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
// Direct FFT // Direct FFT
d_fft_if = new gr::fft::fft_complex(d_fft_size, true); d_fft_if = std::make_shared<gr::fft::fft_complex>(d_fft_size, true);
// Inverse FFT // Inverse FFT
d_ifft = new gr::fft::fft_complex(d_fft_size, false); d_ifft = std::make_shared<gr::fft::fft_complex>(d_fft_size, false);
// For dumping samples into a file // For dumping samples into a file
d_dump = conf_.dump; d_dump = conf_.dump;
@ -168,6 +168,7 @@ unsigned int pcps_acquisition_fine_doppler_cc::nextPowerOf2(unsigned int n)
return n; return n;
} }
void pcps_acquisition_fine_doppler_cc::set_doppler_step(unsigned int doppler_step) void pcps_acquisition_fine_doppler_cc::set_doppler_step(unsigned int doppler_step)
{ {
d_doppler_step = doppler_step; d_doppler_step = doppler_step;
@ -208,8 +209,6 @@ pcps_acquisition_fine_doppler_cc::~pcps_acquisition_fine_doppler_cc()
volk_gnsssdr_free(d_fft_codes); volk_gnsssdr_free(d_fft_codes);
volk_gnsssdr_free(d_magnitude); volk_gnsssdr_free(d_magnitude);
volk_gnsssdr_free(d_10_ms_buffer); volk_gnsssdr_free(d_10_ms_buffer);
delete d_ifft;
delete d_fft_if;
free_grid_memory(); free_grid_memory();
} }

View File

@ -58,6 +58,7 @@
#include <gnuradio/gr_complex.h> #include <gnuradio/gr_complex.h>
#include <cstdint> #include <cstdint>
#include <fstream> #include <fstream>
#include <memory>
#include <string> #include <string>
#include <utility> #include <utility>
@ -109,8 +110,8 @@ private:
float** d_grid_data; float** d_grid_data;
gr_complex** d_grid_doppler_wipeoffs; gr_complex** d_grid_doppler_wipeoffs;
gr::fft::fft_complex* d_fft_if; std::shared_ptr<gr::fft::fft_complex> d_fft_if;
gr::fft::fft_complex* d_ifft; std::shared_ptr<gr::fft::fft_complex> d_ifft;
Gnss_Synchro* d_gnss_synchro; Gnss_Synchro* d_gnss_synchro;
unsigned int d_code_phase; unsigned int d_code_phase;
float d_doppler_freq; float d_doppler_freq;

View File

@ -82,10 +82,10 @@ pcps_assisted_acquisition_cc::pcps_assisted_acquisition_cc(
d_carrier = static_cast<gr_complex *>(volk_gnsssdr_malloc(d_fft_size * sizeof(gr_complex), volk_gnsssdr_get_alignment())); d_carrier = static_cast<gr_complex *>(volk_gnsssdr_malloc(d_fft_size * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
// Direct FFT // Direct FFT
d_fft_if = new gr::fft::fft_complex(d_fft_size, true); d_fft_if = std::make_shared<gr::fft::fft_complex>(d_fft_size, true);
// Inverse FFT // Inverse FFT
d_ifft = new gr::fft::fft_complex(d_fft_size, false); d_ifft = std::make_shared<gr::fft::fft_complex>(d_fft_size, false);
// For dumping samples into a file // For dumping samples into a file
d_dump = dump; d_dump = dump;
@ -129,8 +129,6 @@ pcps_assisted_acquisition_cc::~pcps_assisted_acquisition_cc()
{ {
volk_gnsssdr_free(d_carrier); volk_gnsssdr_free(d_carrier);
volk_gnsssdr_free(d_fft_codes); volk_gnsssdr_free(d_fft_codes);
delete d_ifft;
delete d_fft_if;
try try
{ {
if (d_dump) if (d_dump)

View File

@ -54,6 +54,7 @@
#include <gnuradio/fft/fft.h> #include <gnuradio/fft/fft.h>
#include <gnuradio/gr_complex.h> #include <gnuradio/gr_complex.h>
#include <fstream> #include <fstream>
#include <memory>
#include <string> #include <string>
#include <utility> #include <utility>
@ -125,8 +126,8 @@ private:
float** d_grid_data; float** d_grid_data;
gr_complex** d_grid_doppler_wipeoffs; gr_complex** d_grid_doppler_wipeoffs;
gr::fft::fft_complex* d_fft_if; std::shared_ptr<gr::fft::fft_complex> d_fft_if;
gr::fft::fft_complex* d_ifft; std::shared_ptr<gr::fft::fft_complex> d_ifft;
Gnss_Synchro* d_gnss_synchro; Gnss_Synchro* d_gnss_synchro;
uint32_t d_code_phase; uint32_t d_code_phase;
float d_doppler_freq; float d_doppler_freq;

View File

@ -97,10 +97,10 @@ pcps_cccwsr_acquisition_cc::pcps_cccwsr_acquisition_cc(
d_magnitude = static_cast<float *>(volk_gnsssdr_malloc(d_fft_size * sizeof(float), volk_gnsssdr_get_alignment())); d_magnitude = static_cast<float *>(volk_gnsssdr_malloc(d_fft_size * sizeof(float), volk_gnsssdr_get_alignment()));
// Direct FFT // Direct FFT
d_fft_if = new gr::fft::fft_complex(d_fft_size, true); d_fft_if = std::make_shared<gr::fft::fft_complex>(d_fft_size, true);
// Inverse FFT // Inverse FFT
d_ifft = new gr::fft::fft_complex(d_fft_size, false); d_ifft = std::make_shared<gr::fft::fft_complex>(d_fft_size, false);
// For dumping samples into a file // For dumping samples into a file
d_dump = dump; d_dump = dump;
@ -137,9 +137,6 @@ pcps_cccwsr_acquisition_cc::~pcps_cccwsr_acquisition_cc()
volk_gnsssdr_free(d_correlation_minus); volk_gnsssdr_free(d_correlation_minus);
volk_gnsssdr_free(d_magnitude); volk_gnsssdr_free(d_magnitude);
delete d_ifft;
delete d_fft_if;
try try
{ {
if (d_dump) if (d_dump)

View File

@ -43,6 +43,7 @@
#include <gnuradio/fft/fft.h> #include <gnuradio/fft/fft.h>
#include <gnuradio/gr_complex.h> #include <gnuradio/gr_complex.h>
#include <fstream> #include <fstream>
#include <memory>
#include <string> #include <string>
#include <utility> #include <utility>
@ -100,8 +101,8 @@ private:
uint32_t d_num_doppler_bins; uint32_t d_num_doppler_bins;
gr_complex* d_fft_code_data; gr_complex* d_fft_code_data;
gr_complex* d_fft_code_pilot; gr_complex* d_fft_code_pilot;
gr::fft::fft_complex* d_fft_if; std::shared_ptr<gr::fft::fft_complex> d_fft_if;
gr::fft::fft_complex* d_ifft; std::shared_ptr<gr::fft::fft_complex> d_ifft;
Gnss_Synchro* d_gnss_synchro; Gnss_Synchro* d_gnss_synchro;
uint32_t d_code_phase; uint32_t d_code_phase;
float d_doppler_freq; float d_doppler_freq;

View File

@ -131,10 +131,10 @@ pcps_opencl_acquisition_cc::pcps_opencl_acquisition_cc(
if (d_opencl != 0) if (d_opencl != 0)
{ {
// Direct FFT // Direct FFT
d_fft_if = new gr::fft::fft_complex(d_fft_size, true); d_fft_if = std::make_shared<gr::fft::fft_complex>(d_fft_size, true);
// Inverse FFT // Inverse FFT
d_ifft = new gr::fft::fft_complex(d_fft_size, false); d_ifft = std::make_shared<gr::fft::fft_complex>(d_fft_size, false);
} }
// For dumping samples into a file // For dumping samples into a file
@ -179,11 +179,6 @@ pcps_opencl_acquisition_cc::~pcps_opencl_acquisition_cc()
clFFT_DestroyPlan(d_cl_fft_plan); clFFT_DestroyPlan(d_cl_fft_plan);
} }
else
{
delete d_ifft;
delete d_fft_if;
}
try try
{ {

View File

@ -123,8 +123,8 @@ private:
gr_complex** d_grid_doppler_wipeoffs; gr_complex** d_grid_doppler_wipeoffs;
uint32_t d_num_doppler_bins; uint32_t d_num_doppler_bins;
gr_complex* d_fft_codes; gr_complex* d_fft_codes;
gr::fft::fft_complex* d_fft_if; std::shared_ptr<gr::fft::fft_complex> d_fft_if;
gr::fft::fft_complex* d_ifft; std::shared_ptr<gr::fft::fft_complex> d_ifft;
Gnss_Synchro* d_gnss_synchro; Gnss_Synchro* d_gnss_synchro;
uint32_t d_code_phase; uint32_t d_code_phase;
float d_doppler_freq; float d_doppler_freq;

View File

@ -106,9 +106,9 @@ pcps_quicksync_acquisition_cc::pcps_quicksync_acquisition_cc(
d_code = new gr_complex[d_samples_per_code](); d_code = new gr_complex[d_samples_per_code]();
// Direct FFT // Direct FFT
d_fft_if = new gr::fft::fft_complex(d_fft_size, true); d_fft_if = std::make_shared<gr::fft::fft_complex>(d_fft_size, true);
// Inverse FFT // Inverse FFT
d_ifft = new gr::fft::fft_complex(d_fft_size, false); d_ifft = std::make_shared<gr::fft::fft_complex>(d_fft_size, false);
// For dumping samples into a file // For dumping samples into a file
d_dump = dump; d_dump = dump;
@ -122,7 +122,6 @@ pcps_quicksync_acquisition_cc::pcps_quicksync_acquisition_cc(
d_threshold = 0; d_threshold = 0;
d_doppler_step = 0; d_doppler_step = 0;
d_grid_doppler_wipeoffs = nullptr; d_grid_doppler_wipeoffs = nullptr;
d_fft_if2 = nullptr;
d_gnss_synchro = nullptr; d_gnss_synchro = nullptr;
d_code_phase = 0; d_code_phase = 0;
d_doppler_freq = 0; d_doppler_freq = 0;
@ -150,8 +149,6 @@ pcps_quicksync_acquisition_cc::~pcps_quicksync_acquisition_cc()
volk_gnsssdr_free(d_magnitude); volk_gnsssdr_free(d_magnitude);
volk_gnsssdr_free(d_magnitude_folded); volk_gnsssdr_free(d_magnitude_folded);
delete d_ifft;
delete d_fft_if;
delete d_code; delete d_code;
delete d_possible_delay; delete d_possible_delay;
delete d_corr_output_f; delete d_corr_output_f;

View File

@ -136,9 +136,8 @@ private:
gr_complex** d_grid_doppler_wipeoffs; gr_complex** d_grid_doppler_wipeoffs;
uint32_t d_num_doppler_bins; uint32_t d_num_doppler_bins;
gr_complex* d_fft_codes; gr_complex* d_fft_codes;
gr::fft::fft_complex* d_fft_if; std::shared_ptr<gr::fft::fft_complex> d_fft_if;
gr::fft::fft_complex* d_fft_if2; std::shared_ptr<gr::fft::fft_complex> d_ifft;
gr::fft::fft_complex* d_ifft;
Gnss_Synchro* d_gnss_synchro; Gnss_Synchro* d_gnss_synchro;
uint32_t d_code_phase; uint32_t d_code_phase;
float d_doppler_freq; float d_doppler_freq;

View File

@ -113,10 +113,10 @@ pcps_tong_acquisition_cc::pcps_tong_acquisition_cc(
d_magnitude = static_cast<float *>(volk_gnsssdr_malloc(d_fft_size * sizeof(float), volk_gnsssdr_get_alignment())); d_magnitude = static_cast<float *>(volk_gnsssdr_malloc(d_fft_size * sizeof(float), volk_gnsssdr_get_alignment()));
// Direct FFT // Direct FFT
d_fft_if = new gr::fft::fft_complex(d_fft_size, true); d_fft_if = std::make_shared<gr::fft::fft_complex>(d_fft_size, true);
// Inverse FFT // Inverse FFT
d_ifft = new gr::fft::fft_complex(d_fft_size, false); d_ifft = std::make_shared<gr::fft::fft_complex>(d_fft_size, false);
// For dumping samples into a file // For dumping samples into a file
d_dump = dump; d_dump = dump;
@ -134,6 +134,7 @@ pcps_tong_acquisition_cc::pcps_tong_acquisition_cc(
d_channel = 0; d_channel = 0;
} }
pcps_tong_acquisition_cc::~pcps_tong_acquisition_cc() pcps_tong_acquisition_cc::~pcps_tong_acquisition_cc()
{ {
if (d_num_doppler_bins > 0) if (d_num_doppler_bins > 0)
@ -150,9 +151,6 @@ pcps_tong_acquisition_cc::~pcps_tong_acquisition_cc()
volk_gnsssdr_free(d_fft_codes); volk_gnsssdr_free(d_fft_codes);
volk_gnsssdr_free(d_magnitude); volk_gnsssdr_free(d_magnitude);
delete d_ifft;
delete d_fft_if;
try try
{ {
if (d_dump) if (d_dump)

View File

@ -121,8 +121,8 @@ private:
uint32_t d_num_doppler_bins; uint32_t d_num_doppler_bins;
gr_complex* d_fft_codes; gr_complex* d_fft_codes;
float** d_grid_data; float** d_grid_data;
gr::fft::fft_complex* d_fft_if; std::shared_ptr<gr::fft::fft_complex> d_fft_if;
gr::fft::fft_complex* d_ifft; std::shared_ptr<gr::fft::fft_complex> d_ifft;
Gnss_Synchro* d_gnss_synchro; Gnss_Synchro* d_gnss_synchro;
uint32_t d_code_phase; uint32_t d_code_phase;
float d_doppler_freq; float d_doppler_freq;