fix mem leak in radio

master
Andre Puschmann 6 years ago
parent b6bb8cb125
commit 4655ad92fe

@ -39,32 +39,40 @@ namespace srslte {
*/ */
class radio { class radio {
public: public:
radio() : tr_local_time(1024 * 10), tr_usrp_time(1024 * 10), tr_tx_time(1024 * 10), tr_is_eob(1024 * 10) { radio() : tr_local_time(1024 * 10), tr_usrp_time(1024 * 10), tr_tx_time(1024 * 10), tr_is_eob(1024 * 10), zeros(NULL)
bzero(&rf_device, sizeof(srslte_rf_t)); {
bzero(&end_of_burst_time, sizeof(srslte_timestamp_t)); bzero(&rf_device, sizeof(srslte_rf_t));
zeros = (cf_t *) srslte_vec_malloc(burst_preamble_max_samples * sizeof (cf_t)); bzero(&end_of_burst_time, sizeof(srslte_timestamp_t));
bzero(zeros, burst_preamble_max_samples * sizeof(cf_t)); zeros = (cf_t*)srslte_vec_malloc(burst_preamble_max_samples * sizeof(cf_t));
bzero(zeros, burst_preamble_max_samples * sizeof(cf_t));
burst_preamble_sec = 0;
is_start_of_burst = false; burst_preamble_sec = 0;
burst_preamble_samples = 0; is_start_of_burst = false;
burst_preamble_time_rounded = 0; burst_preamble_samples = 0;
burst_preamble_time_rounded = 0;
cur_tx_srate = 0;
tx_adv_sec = 0; cur_tx_srate = 0;
tx_adv_nsamples = 0; tx_adv_sec = 0;
tx_adv_auto = false; tx_adv_nsamples = 0;
tx_adv_negative = false; tx_adv_auto = false;
tx_freq = 0; tx_adv_negative = false;
rx_freq = 0; tx_freq = 0;
trace_enabled = false; rx_freq = 0;
tti = 0; trace_enabled = false;
agc_enabled = false; tti = 0;
radio_is_streaming = false; agc_enabled = false;
is_initialized = false; radio_is_streaming = false;
continuous_tx = false; is_initialized = false;
continuous_tx = false;
}; };
~radio()
{
if (zeros) {
free(zeros);
}
}
bool init(char *args = NULL, char *devname = NULL, uint32_t nof_channels = 1); bool init(char *args = NULL, char *devname = NULL, uint32_t nof_channels = 1);
void stop(); void stop();
void reset(); void reset();

@ -81,9 +81,6 @@ bool radio::is_init() {
void radio::stop() void radio::stop()
{ {
if (zeros) {
free(zeros);
}
if (is_initialized) { if (is_initialized) {
srslte_rf_close(&rf_device); srslte_rf_close(&rf_device);
} }

Loading…
Cancel
Save