Fix memory leaks in unit tests

master
Ismael Gomez 7 years ago
parent 3a9f144ff3
commit 4ffee4326b

@ -301,7 +301,6 @@ int srslte_chest_ul_estimate(srslte_chest_ul_t *q, cf_t *input, cf_t *ce,
q->noise_estimate = 0;
}
}
// Estimate received pilot power
q->pilot_power = srslte_vec_avg_power_cf(q->pilot_recv_signal, nrefs_sf);
return 0;

@ -117,6 +117,7 @@ int main(int argc, char **argv) {
perror("srslte_vec_malloc");
goto do_exit;
}
bzero(ce, num_re*sizeof(cf_t));
if (cell.id == 1000) {
cid = 0;

@ -244,6 +244,7 @@ int main(int argc, char **argv) {
for (j=0;j<coded_length;j++) {
llr_s[j] = (int16_t) (100*llr[j]);
}
/* decoder */
srslte_tdec_reset(&tdec, frame_length);
@ -260,10 +261,11 @@ int main(int argc, char **argv) {
for (int n=0;n<SRSLTE_TDEC_MAX_NPAR;n++) {
if (n < nof_cb) {
input[n] = llr_s;
output[n] = data_rx_bytes[n];
} else {
input[n] = NULL;
output[n] = NULL;
}
output[n] = data_rx_bytes[n];
}
gettimeofday(&tdata[1], NULL);
@ -299,11 +301,16 @@ int main(int argc, char **argv) {
}
}
for (int cb=0;cb<SRSLTE_TDEC_MAX_NPAR;cb++) {
if (data_rx_bytes[cb]) {
free(data_rx_bytes[cb]);
}
}
free(data_tx);
free(symbols);
free(llr);
free(llr_c);
free(llr_s);
free(data_rx);
srslte_tdec_free(&tdec);

@ -278,6 +278,7 @@ int main(int argc, char **argv) {
free(symbols);
free(llr);
free(llr_c);
free(llr_s);
free(data_rx);
free(data_rx2);

@ -513,7 +513,9 @@ void srslte_tdec_simd_decision_byte_cb(srslte_tdec_simd_t * h, uint8_t *output,
void srslte_tdec_simd_decision_byte(srslte_tdec_simd_t * h, uint8_t *output[SRSLTE_TDEC_MAX_NPAR], uint32_t long_cb)
{
for (int i=0;i<h->max_par_cb;i++) {
srslte_tdec_simd_decision_byte_cb(h, output[i], i, long_cb);
if (output[i]) {
srslte_tdec_simd_decision_byte_cb(h, output[i], i, long_cb);
}
}
}

@ -333,5 +333,11 @@ int main(int argc, char **argv) {
}
}
for (i = 0; i < nof_tx_ports; i++) {
if (y[i]) {
free(y[i]);
}
}
exit(ret);
}

@ -232,6 +232,8 @@ int main(int argc, char **argv) {
} while(nread > 0 && frame_cnt < nof_frames);
base_free();
srslte_dft_exit();
if (frame_cnt == 1) {
if (n == 0) {
printf("Could not decode PBCH\n");

@ -144,6 +144,7 @@ int main(int argc, char **argv) {
srslte_vec_fprint_hex(stdout, bch_payload_tx, SRSLTE_BCH_PAYLOAD_LEN);
printf("Rx payload: ");
srslte_vec_fprint_hex(stdout, bch_payload_rx, SRSLTE_BCH_PAYLOAD_LEN);
srslte_dft_exit();
if (nof_rx_ports == cell.nof_ports && !memcmp(bch_payload_rx, bch_payload_tx, sizeof(uint8_t) * SRSLTE_BCH_PAYLOAD_LEN)) {
printf("OK\n");

@ -239,6 +239,7 @@ int main(int argc, char **argv) {
printf("cfi: %d, distance: %f\n", cfi, cfi_corr);
base_free();
srslte_dft_exit();
if (n < 0) {
fprintf(stderr, "Error decoding PCFICH\n");

@ -154,6 +154,7 @@ int main(int argc, char **argv) {
srslte_regs_free(&regs);
cid++;
}
srslte_dft_exit();
for (i=0;i<SRSLTE_MAX_PORTS;i++) {
free(ce[i]);

@ -288,5 +288,6 @@ int main(int argc, char **argv) {
} while (frame_cnt <= max_frames);
base_free();
srslte_dft_exit();
exit(ret);
}

@ -359,5 +359,6 @@ quit:
} else {
printf("Ok\n");
}
srslte_dft_exit();
exit(ret);
}

@ -162,6 +162,7 @@ int main(int argc, char **argv) {
int nof_frames;
int ret;
bool acks[SRSLTE_MAX_TB];
bzero(acks, sizeof(bool)*SRSLTE_MAX_TB);
if (argc < 3) {
usage(argv[0]);
@ -199,6 +200,7 @@ int main(int argc, char **argv) {
} while (nof_frames <= max_frames && ret == 0);
base_free();
srslte_dft_exit();
if (data[0])
free(data[0]);
if (ret > 0) {

@ -546,5 +546,6 @@ quit:
} else {
printf("Ok\n");
}
srslte_dft_exit();
exit(ret);
}

@ -278,6 +278,7 @@ int main(int argc, char **argv) {
}
base_free();
srslte_dft_exit();
if (n < 0) {
fprintf(stderr, "Error decoding phich\n");

@ -215,6 +215,7 @@ int main(int argc, char **argv) {
}
free(slot_symbols[i]);
}
srslte_dft_exit();
printf("OK\n");
exit(0);
}

@ -202,6 +202,7 @@ int main(int argc, char **argv) {
if (data != NULL) {
free(data);
}
srslte_dft_exit();
if (ret > 0) {
exit(0);
} else {

@ -430,6 +430,15 @@ int main(int argc, char **argv) {
ret = SRSLTE_SUCCESS;
quit:
for (i = 0; i < nof_rx_antennas; i++) {
srslte_ofdm_tx_free(&ifft_mbsfn[i]);
srslte_ofdm_rx_free(&fft_mbsfn[i]);
if (rx_sf_symbols[i]) {
free(rx_sf_symbols[i]);
}
}
srslte_pmch_free(&pmch_tx);
srslte_pmch_free(&pmch_rx);
for (i = 0; i < SRSLTE_MAX_CODEWORDS; i++) {
@ -453,6 +462,9 @@ quit:
}
for (i=0;i<SRSLTE_MAX_PORTS;i++) {
if (tx_sf_symbols[i]) {
free(tx_sf_symbols[i]);
}
for (j = 0; j < SRSLTE_MAX_PORTS; j++) {
if (ce[i][j]) {
free(ce[i][j]);

@ -123,6 +123,7 @@ int main(int argc, char **argv) {
srslte_prach_free(p);
free(p);
srslte_dft_exit();
printf("Done\n");
exit(0);

@ -138,7 +138,7 @@ int main(int argc, char **argv) {
srslte_prach_free(p);
free(p);
printf("Done\n");
exit(0);
srslte_dft_exit();
printf("Done\n");
exit(0);
}

@ -235,6 +235,7 @@ int main(int argc, char **argv) {
srslte_rf_close(&rf);
srslte_prach_free(p);
free(p);
srslte_dft_exit();
printf("Done\n");
exit(0);

@ -244,5 +244,6 @@ quit:
} else {
printf("Ok\n");
}
srslte_dft_exit();
exit(ret);
}

@ -295,6 +295,7 @@ quit:
srslte_pusch_free(&pusch_tx);
srslte_pusch_free(&pusch_rx);
srslte_softbuffer_tx_free(&softbuffer_tx);
srslte_softbuffer_rx_free(&softbuffer_rx);
if (sf_symbols) {
free(sf_symbols);
@ -310,5 +311,6 @@ quit:
} else {
printf("Ok\n");
}
srslte_dft_exit();
exit(ret);
}

@ -106,6 +106,7 @@ int main(int argc, char **argv) {
srslte_cfo_free(&cfocorr);
free(input);
free(output);
srslte_dft_exit();
printf("MSE: %f\n", mse);
if (mse > MAX_MSE) {

@ -185,6 +185,7 @@ int main(int argc, char **argv) {
srslte_sync_free(&syncobj);
srslte_ofdm_tx_free(&ifft);
srslte_dft_exit();
printf("Ok\n");
exit(0);

@ -49,26 +49,27 @@ void* write_thread(void *a) {
int main(int argc, char **argv) {
bool result;
msg_queue q;
msg_queue *q = new msg_queue;
byte_buffer_t *b;
pthread_t thread;
args_t args;
u_int32_t r;
result = true;
args.q = &q;
args.q = q;
pthread_create(&thread, NULL, &write_thread, &args);
for(uint32_t i=0;i<NMSGS;i++)
{
q.read(&b);
q->read(&b);
memcpy(&r, b->msg, 4);
delete b;
if(r != i)
result = false;
}
delete q;
pthread_join(thread, NULL);
if(result) {

@ -51,8 +51,11 @@ void nas_test() {
uint8 msg_type;
LIBLTE_BYTE_MSG_STRUCT buf;
LIBLTE_MME_ATTACH_ACCEPT_MSG_STRUCT attach_accept;
bzero(&attach_accept, sizeof(LIBLTE_MME_ATTACH_ACCEPT_MSG_STRUCT));
LIBLTE_MME_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_MSG_STRUCT act_def_eps_bearer_context_req;
bzero(&act_def_eps_bearer_context_req, sizeof(LIBLTE_MME_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_MSG_STRUCT));
bzero(&buf, sizeof(LIBLTE_BYTE_MSG_STRUCT));
memcpy(buf.msg, nas_message, nas_message_len);
buf.N_bytes = nas_message_len;
liblte_mme_parse_msg_header(&buf, &pd, &msg_type);

Loading…
Cancel
Save