gNB: fix allocation of RC.gNB[] array
If the array of pointers is allocated using malloc(), it is not guaranteed that the pointers are NULL, so the actual PHY_VARS_gNB might nit be allocated correctly! Also replace a malloc() + memset() combination by just a calloc().
This commit is contained in:
@@ -468,15 +468,14 @@ void init_gNB(int single_thread_flag,int wait_for_sync) {
|
|||||||
PHY_VARS_gNB *gNB;
|
PHY_VARS_gNB *gNB;
|
||||||
|
|
||||||
if (RC.gNB == NULL) {
|
if (RC.gNB == NULL) {
|
||||||
RC.gNB = (PHY_VARS_gNB **) malloc((1+RC.nb_nr_L1_inst)*sizeof(PHY_VARS_gNB *));
|
RC.gNB = (PHY_VARS_gNB **) calloc(1+RC.nb_nr_L1_inst, sizeof(PHY_VARS_gNB *));
|
||||||
LOG_I(PHY,"gNB L1 structure RC.gNB allocated @ %p\n",RC.gNB);
|
LOG_I(PHY,"gNB L1 structure RC.gNB allocated @ %p\n",RC.gNB);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (inst=0; inst<RC.nb_nr_L1_inst; inst++) {
|
for (inst=0; inst<RC.nb_nr_L1_inst; inst++) {
|
||||||
|
|
||||||
if (RC.gNB[inst] == NULL) {
|
if (RC.gNB[inst] == NULL) {
|
||||||
RC.gNB[inst] = (PHY_VARS_gNB *) malloc(sizeof(PHY_VARS_gNB));
|
RC.gNB[inst] = (PHY_VARS_gNB *) calloc(1, sizeof(PHY_VARS_gNB));
|
||||||
memset((void*)RC.gNB[inst],0,sizeof(PHY_VARS_gNB));
|
|
||||||
LOG_I(PHY,"[nr-gnb.c] gNB structure RC.gNB[%d] allocated @ %p\n",inst,RC.gNB[inst]);
|
LOG_I(PHY,"[nr-gnb.c] gNB structure RC.gNB[%d] allocated @ %p\n",inst,RC.gNB[inst]);
|
||||||
}
|
}
|
||||||
gNB = RC.gNB[inst];
|
gNB = RC.gNB[inst];
|
||||||
|
|||||||
Reference in New Issue
Block a user