Commit 40f2f543 authored by Roberto Louro Magueta's avatar Roberto Louro Magueta

Fix memory allocation for SRS

parent 58102d24
......@@ -616,8 +616,8 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB,
for (int id=0; id<NUMBER_OF_NR_SRS_MAX; id++) {
gNB->nr_srs_info[id] = (nr_srs_info_t *)malloc16_clear(sizeof(nr_srs_info_t));
gNB->nr_srs_info[id]->k_0_p = (uint8_t**)malloc16_clear(Prx*sizeof(uint8_t*));
gNB->nr_srs_info[id]->srs_generated_signal = (int32_t**)malloc16_clear(Prx*sizeof(int32_t*));
gNB->nr_srs_info[id]->k_0_p = (uint8_t**)malloc16_clear(MAX_NUM_NR_SRS_AP*sizeof(uint8_t*));
gNB->nr_srs_info[id]->srs_generated_signal = (int32_t**)malloc16_clear(MAX_NUM_NR_SRS_AP*sizeof(int32_t*));
gNB->nr_srs_info[id]->signal_power = (uint32_t*)malloc16_clear(sizeof(uint32_t));
gNB->nr_srs_info[id]->noise_power_per_rb = (uint32_t*)malloc16_clear(fp->N_RB_UL*sizeof(uint32_t));
gNB->nr_srs_info[id]->noise_power = (uint32_t*)malloc16_clear(sizeof(uint32_t));
......@@ -628,15 +628,17 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB,
gNB->nr_srs_info[id]->srs_estimated_channel_freq = (int32_t ***)malloc16(Prx*sizeof(int32_t**));
gNB->nr_srs_info[id]->srs_estimated_channel_time = (int32_t ***)malloc16(Prx*sizeof(int32_t**));
gNB->nr_srs_info[id]->srs_estimated_channel_time_shifted = (int32_t ***)malloc16(Prx*sizeof(int32_t**));
for (i=0;i<Prx;i++){
for(i=0; i<MAX_NUM_NR_SRS_AP;i++) {
gNB->nr_srs_info[id]->k_0_p[i] = (uint8_t*)malloc16_clear(MAX_NUM_NR_SRS_SYMBOLS*sizeof(uint8_t));
gNB->nr_srs_info[id]->srs_generated_signal[i] = (int32_t*)malloc16_clear(fp->ofdm_symbol_size*MAX_NUM_NR_SRS_SYMBOLS*sizeof(int32_t));
}
for (i=0;i<Prx;i++) {
gNB->nr_srs_info[id]->srs_received_signal[i] = (int32_t*)malloc16_clear(fp->ofdm_symbol_size*MAX_NUM_NR_SRS_SYMBOLS*sizeof(int32_t));
gNB->nr_srs_info[id]->srs_ls_estimated_channel[i] = (int32_t**)malloc16_clear(Prx*sizeof(int32_t*));
gNB->nr_srs_info[id]->srs_estimated_channel_freq[i] = (int32_t**)malloc16_clear(Prx*sizeof(int32_t*));
gNB->nr_srs_info[id]->srs_estimated_channel_time[i] = (int32_t**)malloc16_clear(Prx*sizeof(int32_t*));
gNB->nr_srs_info[id]->srs_estimated_channel_time_shifted[i] = (int32_t**)malloc16_clear(Prx*sizeof(int32_t*));
for (int j = 0; j < Prx; j++) {
gNB->nr_srs_info[id]->srs_ls_estimated_channel[i] = (int32_t**)malloc16_clear(MAX_NUM_NR_SRS_AP*sizeof(int32_t*));
gNB->nr_srs_info[id]->srs_estimated_channel_freq[i] = (int32_t**)malloc16_clear(MAX_NUM_NR_SRS_AP*sizeof(int32_t*));
gNB->nr_srs_info[id]->srs_estimated_channel_time[i] = (int32_t**)malloc16_clear(MAX_NUM_NR_SRS_AP*sizeof(int32_t*));
gNB->nr_srs_info[id]->srs_estimated_channel_time_shifted[i] = (int32_t**)malloc16_clear(MAX_NUM_NR_SRS_AP*sizeof(int32_t*));
for (int j = 0; j < MAX_NUM_NR_SRS_AP; j++) {
gNB->nr_srs_info[id]->srs_ls_estimated_channel[i][j] = (int32_t*)malloc16_clear(fp->ofdm_symbol_size*MAX_NUM_NR_SRS_SYMBOLS*sizeof(int32_t));
gNB->nr_srs_info[id]->srs_estimated_channel_freq[i][j] = (int32_t*)malloc16_clear(fp->ofdm_symbol_size*MAX_NUM_NR_SRS_SYMBOLS*sizeof(int32_t));
gNB->nr_srs_info[id]->srs_estimated_channel_time[i][j] = (int32_t*)malloc16_clear(fp->ofdm_symbol_size*MAX_NUM_NR_SRS_SYMBOLS*sizeof(int32_t));
......@@ -799,20 +801,22 @@ void phy_free_nr_gNB(PHY_VARS_gNB *gNB)
for (int id = 0; id < NUMBER_OF_NR_SRS_MAX; id++) {
for (int i = 0; i < Prx; i++) {
free_and_zero(gNB->nr_srs_info[id]->k_0_p[i]);
free_and_zero(gNB->nr_srs_info[id]->srs_generated_signal[i]);
free_and_zero(gNB->nr_srs_info[id]->srs_received_signal[i]);
for (int j = 0; j < Prx; j++) {
for (int j = 0; j < MAX_NUM_NR_SRS_AP; j++) {
free_and_zero(gNB->nr_srs_info[id]->srs_ls_estimated_channel[i][j]);
free_and_zero(gNB->nr_srs_info[id]->srs_estimated_channel_freq[i][j]);
free_and_zero(gNB->nr_srs_info[id]->srs_estimated_channel_time[i][j]);
free_and_zero(gNB->nr_srs_info[id]->srs_estimated_channel_time_shifted[i][j]);
}
free_and_zero(gNB->nr_srs_info[id]->srs_received_signal[i]);
free_and_zero(gNB->nr_srs_info[id]->srs_ls_estimated_channel[i]);
free_and_zero(gNB->nr_srs_info[id]->srs_estimated_channel_freq[i]);
free_and_zero(gNB->nr_srs_info[id]->srs_estimated_channel_time[i]);
free_and_zero(gNB->nr_srs_info[id]->srs_estimated_channel_time_shifted[i]);
}
for (int i = 0; i < MAX_NUM_NR_SRS_AP; i++) {
free_and_zero(gNB->nr_srs_info[id]->k_0_p[i]);
free_and_zero(gNB->nr_srs_info[id]->srs_generated_signal[i]);
}
free_and_zero(gNB->nr_srs_info[id]->k_0_p);
free_and_zero(gNB->nr_srs_info[id]->srs_generated_signal);
free_and_zero(gNB->nr_srs_info[id]->signal_power);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment