fix mem leak in radio

master
Andre Puschmann 6 years ago
parent b6bb8cb125
commit 4655ad92fe

@ -39,7 +39,8 @@ 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(&rf_device, sizeof(srslte_rf_t));
bzero(&end_of_burst_time, sizeof(srslte_timestamp_t)); bzero(&end_of_burst_time, sizeof(srslte_timestamp_t));
zeros = (cf_t*)srslte_vec_malloc(burst_preamble_max_samples * sizeof(cf_t)); zeros = (cf_t*)srslte_vec_malloc(burst_preamble_max_samples * sizeof(cf_t));
@ -65,6 +66,13 @@ class radio {
continuous_tx = 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