From 2cc06c8b632be3119c0b5a394830de870f94f06d Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 30 Jun 2019 12:10:14 +0200 Subject: [PATCH] Remove delete in FPGA adapters --- .../galileo_e1_pcps_ambiguous_acquisition_fpga.cc | 11 +++++------ .../adapters/galileo_e5a_pcps_acquisition_fpga.cc | 7 +++---- .../adapters/gps_l1_ca_pcps_acquisition_fpga.cc | 7 +++---- .../adapters/gps_l2_m_pcps_acquisition_fpga.cc | 12 ++++++------ .../adapters/gps_l5i_pcps_acquisition_fpga.cc | 5 ++--- 5 files changed, 19 insertions(+), 23 deletions(-) diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc index 0742b0ff5..e1021b6b7 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc @@ -108,12 +108,12 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga( // compute all the GALILEO E1 PRN Codes (this is done only once in the class constructor in order to avoid re-computing the PRN codes every time // a channel is assigned) - auto* fft_if = new gr::fft::fft_complex(nsamples_total, true); // Direct FFT - //auto code = std::make_shared>(nsamples_total); // buffer for the local code - std::vector> code(nsamples_total); + auto fft_if = std::unique_ptr(new gr::fft::fft_complex(nsamples_total, true)); // Direct FFT + std::vector> code(nsamples_total); // buffer for the local code auto* fft_codes_padded = static_cast(volk_gnsssdr_malloc(nsamples_total * sizeof(gr_complex), volk_gnsssdr_get_alignment())); d_all_fft_codes_ = std::vector(nsamples_total * GALILEO_E1_NUMBER_OF_CODES); // memory containing all the possible fft codes for PRN 0 to 32 - float max; // temporary maxima search + + float max; // temporary maxima search int32_t tmp, tmp2, local_code, fft_data; for (uint32_t PRN = 1; PRN <= GALILEO_E1_NUMBER_OF_CODES; PRN++) @@ -189,8 +189,7 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga( doppler_step_ = 0; gnss_synchro_ = nullptr; - // temporary buffers that we can delete - delete fft_if; + // temporary buffers that we can release volk_gnsssdr_free(fft_codes_padded); } diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc index 54f367158..a0bd49ba0 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc @@ -109,8 +109,8 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf // compute all the GALILEO E5 PRN Codes (this is done only once in the class constructor in order to avoid re-computing the PRN codes every time // a channel is assigned) - auto* fft_if = new gr::fft::fft_complex(nsamples_total, true); // Direct FFT - std::vector> code(nsamples_total); // buffer for the local code + auto fft_if = std::unique_ptr(new gr::fft::fft_complex(nsamples_total, true)); // Direct FFT + std::vector> code(nsamples_total); // buffer for the local code auto* fft_codes_padded = static_cast(volk_gnsssdr_malloc(nsamples_total * sizeof(gr_complex), volk_gnsssdr_get_alignment())); d_all_fft_codes_ = std::vector(nsamples_total * GALILEO_E5A_NUMBER_OF_CODES); // memory containing all the possible fft codes for PRN 0 to 32 @@ -192,8 +192,7 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf doppler_step_ = 0; gnss_synchro_ = nullptr; - // temporary buffers that we can delete - delete fft_if; + // temporary buffers that we can release volk_gnsssdr_free(fft_codes_padded); } diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc index a1307b68f..7216d09d5 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc @@ -103,7 +103,7 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( // compute all the GPS L1 PRN Codes (this is done only once upon the class constructor in order to avoid re-computing the PRN codes every time // a channel is assigned) - auto* fft_if = new gr::fft::fft_complex(nsamples_total, true); // Direct FFT + auto fft_if = std::unique_ptr(new gr::fft::fft_complex(nsamples_total, true)); // allocate memory to compute all the PRNs and compute all the possible codes std::vector> code(nsamples_total); // buffer for the local code auto* fft_codes_padded = static_cast(volk_gnsssdr_malloc(nsamples_total * sizeof(gr_complex), volk_gnsssdr_get_alignment())); @@ -154,7 +154,7 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( } } - //acq_parameters + // acq_parameters acq_parameters.all_fft_codes = d_all_fft_codes_.data(); // reference for the FPGA FFT-IFFT attenuation factor @@ -170,8 +170,7 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( doppler_step_ = 0; gnss_synchro_ = nullptr; - // temporary buffers that we can delete - delete fft_if; + // temporary buffers that we can release volk_gnsssdr_free(fft_codes_padded); } diff --git a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.cc index a92f5c158..17d98fc25 100644 --- a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.cc @@ -102,12 +102,13 @@ GpsL2MPcpsAcquisitionFpga::GpsL2MPcpsAcquisitionFpga( // compute all the GPS L2C PRN Codes (this is done only once upon the class constructor in order to avoid re-computing the PRN codes every time // a channel is assigned) - auto* fft_if = new gr::fft::fft_complex(vector_length, true); // Direct FFT + auto fft_if = std::unique_ptr(new gr::fft::fft_complex(nsamples_total, true)); // Direct FFT // allocate memory to compute all the PRNs and compute all the possible codes std::vector> code(nsamples_total); // buffer for the local code auto* fft_codes_padded = static_cast(volk_gnsssdr_malloc(nsamples_total * sizeof(gr_complex), volk_gnsssdr_get_alignment())); d_all_fft_codes_ = std::vector(nsamples_total * NUM_PRNs); // memory containing all the possible fft codes for PRN 0 to 32 - float max; // temporary maxima search + + float max; // temporary maxima search int32_t tmp, tmp2, local_code, fft_data; for (unsigned int PRN = 1; PRN <= NUM_PRNs; PRN++) @@ -150,10 +151,6 @@ GpsL2MPcpsAcquisitionFpga::GpsL2MPcpsAcquisitionFpga( acq_parameters.all_fft_codes = d_all_fft_codes_.data(); - // temporary buffers that we can delete - delete fft_if; - volk_gnsssdr_free(fft_codes_padded); - acquisition_fpga_ = pcps_make_acquisition_fpga(acq_parameters); channel_ = 0; @@ -161,6 +158,9 @@ GpsL2MPcpsAcquisitionFpga::GpsL2MPcpsAcquisitionFpga( gnss_synchro_ = nullptr; threshold_ = 0.0; + + // temporary buffers that we can release + volk_gnsssdr_free(fft_codes_padded); } diff --git a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc index c25f65672..30bd9d407 100644 --- a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc @@ -108,7 +108,7 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga( // compute all the GPS L5 PRN Codes (this is done only once upon the class constructor in order to avoid re-computing the PRN codes every time // a channel is assigned) - auto* fft_if = new gr::fft::fft_complex(nsamples_total, true); // Direct FFT + auto fft_if = std::unique_ptr(new gr::fft::fft_complex(nsamples_total, true)); // Direct FFT std::vector> code(nsamples_total); auto* fft_codes_padded = static_cast(volk_gnsssdr_malloc(nsamples_total * sizeof(gr_complex), volk_gnsssdr_get_alignment())); d_all_fft_codes_ = std::vector(nsamples_total * NUM_PRNs); // memory containing all the possible fft codes for PRN 0 to 32 @@ -173,8 +173,7 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga( doppler_step_ = 0; gnss_synchro_ = nullptr; - // temporary buffers that we can delete - delete fft_if; + // temporary buffers that we can release volk_gnsssdr_free(fft_codes_padded); }