Commit 0f720d39 authored by francescomani's avatar francescomani

macro based on ASN_STRUCT_RESET to replace ASN_STRUCT_FREE because the latter...

macro based on ASN_STRUCT_RESET to replace ASN_STRUCT_FREE because the latter does not reset to NULL pointers inside the structure
parent 6dc9ec77
...@@ -117,5 +117,11 @@ static inline uint64_t BIT_STRING_to_uint64(BIT_STRING_t *asn) { ...@@ -117,5 +117,11 @@ static inline uint64_t BIT_STRING_to_uint64(BIT_STRING_t *asn) {
#define asn1cSequenceAdd(VaR, TyPe, lOcPtr) \ #define asn1cSequenceAdd(VaR, TyPe, lOcPtr) \
TyPe *lOcPtr= calloc(1,sizeof(TyPe)); \ TyPe *lOcPtr= calloc(1,sizeof(TyPe)); \
asn1cSeqAdd(&VaR,lOcPtr) asn1cSeqAdd(&VaR,lOcPtr)
#define asn1cFreeStruc(ASN_DEF, STRUCT) \
do { \
ASN_STRUCT_RESET(ASN_DEF, STRUCT); \
free(STRUCT); \
STRUCT = NULL; \
} while (0)
#endif #endif
This diff is collapsed.
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#define __LAYER2_MAC_UE_PROTO_H__ #define __LAYER2_MAC_UE_PROTO_H__
#include "mac_defs.h" #include "mac_defs.h"
#include "oai_asn1.h"
#include "RRC/NR_UE/rrc_defs.h" #include "RRC/NR_UE/rrc_defs.h"
#define NR_DL_MAX_DAI (4) /* TS 38.213 table 9.1.3-1 Value of counter DAI for DCI format 1_0 and 1_1 */ #define NR_DL_MAX_DAI (4) /* TS 38.213 table 9.1.3-1 Value of counter DAI for DCI format 1_0 and 1_1 */
...@@ -49,8 +50,7 @@ ...@@ -49,8 +50,7 @@
#define HANDLE_SETUPRELEASE_DIRECT(DESTINATION, ORIGIN, TYPE, ASN_DEF) \ #define HANDLE_SETUPRELEASE_DIRECT(DESTINATION, ORIGIN, TYPE, ASN_DEF) \
do { \ do { \
if (ORIGIN->present == 1) { \ if (ORIGIN->present == 1) { \
ASN_STRUCT_FREE(ASN_DEF, DESTINATION); \ asn1cFreeStruc(ASN_DEF, DESTINATION); \
DESTINATION = NULL; \
} \ } \
if (ORIGIN->present == 2) \ if (ORIGIN->present == 2) \
UPDATE_MAC_IE(DESTINATION, ORIGIN->choice.setup, TYPE); \ UPDATE_MAC_IE(DESTINATION, ORIGIN->choice.setup, TYPE); \
...@@ -59,8 +59,7 @@ ...@@ -59,8 +59,7 @@
#define HANDLE_SETUPRELEASE_IE(DESTINATION, ORIGIN, TYPE, ASN_DEF) \ #define HANDLE_SETUPRELEASE_IE(DESTINATION, ORIGIN, TYPE, ASN_DEF) \
do { \ do { \
if (ORIGIN->present == 1) { \ if (ORIGIN->present == 1) { \
ASN_STRUCT_FREE(ASN_DEF, DESTINATION); \ asn1cFreeStruc(ASN_DEF, DESTINATION); \
DESTINATION = NULL; \
} \ } \
if (ORIGIN->present == 2) { \ if (ORIGIN->present == 2) { \
if (!DESTINATION) \ if (!DESTINATION) \
...@@ -123,7 +122,6 @@ ...@@ -123,7 +122,6 @@
} \ } \
} while (0) } while (0)
/**\brief initialize the field in nr_mac instance /**\brief initialize the field in nr_mac instance
\param module_id module id */ \param module_id module id */
void nr_ue_init_mac(module_id_t module_idP); void nr_ue_init_mac(module_id_t module_idP);
......
...@@ -181,10 +181,7 @@ void reset_mac_inst(NR_UE_MAC_INST_t *nr_mac) ...@@ -181,10 +181,7 @@ void reset_mac_inst(NR_UE_MAC_INST_t *nr_mac)
void release_mac_configuration(NR_UE_MAC_INST_t *mac) void release_mac_configuration(NR_UE_MAC_INST_t *mac)
{ {
if(mac->mib) { asn1cFreeStruc(asn_DEF_NR_MIB, mac->mib);
ASN_STRUCT_FREE(asn_DEF_NR_MIB, mac->mib);
mac->mib = NULL;
}
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
NR_BWP_PDCCH_t *pdcch = &mac->config_BWP_PDCCH[5]; NR_BWP_PDCCH_t *pdcch = &mac->config_BWP_PDCCH[5];
release_common_ss_cset(pdcch); release_common_ss_cset(pdcch);
...@@ -204,6 +201,6 @@ void release_mac_configuration(NR_UE_MAC_INST_t *mac) ...@@ -204,6 +201,6 @@ void release_mac_configuration(NR_UE_MAC_INST_t *mac)
void reset_ra(RA_config_t *ra) void reset_ra(RA_config_t *ra)
{ {
if(ra->rach_ConfigDedicated) if(ra->rach_ConfigDedicated)
ASN_STRUCT_FREE(asn_DEF_NR_RACH_ConfigDedicated, ra->rach_ConfigDedicated); asn1cFreeStruc(asn_DEF_NR_RACH_ConfigDedicated, ra->rach_ConfigDedicated);
memset(ra, 0, sizeof(RA_config_t)); memset(ra, 0, sizeof(RA_config_t));
} }
...@@ -688,8 +688,7 @@ static int8_t nr_rrc_ue_decode_NR_BCCH_DL_SCH_Message(instance_t instance, ...@@ -688,8 +688,7 @@ static int8_t nr_rrc_ue_decode_NR_BCCH_DL_SCH_Message(instance_t instance,
switch (bcch_message->message.choice.c1->present) { switch (bcch_message->message.choice.c1->present) {
case NR_BCCH_DL_SCH_MessageType__c1_PR_systemInformationBlockType1: case NR_BCCH_DL_SCH_MessageType__c1_PR_systemInformationBlockType1:
LOG_D(NR_RRC, "[UE %ld] Decoding SIB1\n", instance); LOG_D(NR_RRC, "[UE %ld] Decoding SIB1\n", instance);
ASN_STRUCT_FREE(asn_DEF_NR_SIB1, SI_info->sib1); asn1cFreeStruc(asn_DEF_NR_SIB1, SI_info->sib1);
SI_info->sib1 = NULL;
NR_SIB1_t *sib1 = bcch_message->message.choice.c1->choice.systemInformationBlockType1; NR_SIB1_t *sib1 = bcch_message->message.choice.c1->choice.systemInformationBlockType1;
if(!SI_info->sib1) if(!SI_info->sib1)
SI_info->sib1 = calloc(1, sizeof(*SI_info->sib1)); SI_info->sib1 = calloc(1, sizeof(*SI_info->sib1));
...@@ -1938,70 +1937,26 @@ void nr_rrc_going_to_IDLE(instance_t instance, ...@@ -1938,70 +1937,26 @@ void nr_rrc_going_to_IDLE(instance_t instance,
} }
} }
if(rrc->meas_config) { asn1cFreeStruc(asn_DEF_NR_MeasConfig, rrc->meas_config);
ASN_STRUCT_FREE(asn_DEF_NR_MeasConfig, rrc->meas_config);
rrc->meas_config = NULL; rrc->meas_config = NULL;
}
for (int i = 0; i < NB_CNX_UE; i++) { for (int i = 0; i < NB_CNX_UE; i++) {
rrcPerNB_t *nb = &rrc->perNB[i]; rrcPerNB_t *nb = &rrc->perNB[i];
NR_UE_RRC_SI_INFO *SI_info = &nb->SInfo; NR_UE_RRC_SI_INFO *SI_info = &nb->SInfo;
if(SI_info->sib1) { asn1cFreeStruc(asn_DEF_NR_SIB1, SI_info->sib1);
ASN_STRUCT_FREE(asn_DEF_NR_SIB1, SI_info->sib1); asn1cFreeStruc(asn_DEF_NR_SIB2, SI_info->sib2);
SI_info->sib1 = NULL; asn1cFreeStruc(asn_DEF_NR_SIB3, SI_info->sib3);
} asn1cFreeStruc(asn_DEF_NR_SIB4, SI_info->sib4);
if(SI_info->sib2) { asn1cFreeStruc(asn_DEF_NR_SIB5, SI_info->sib5);
ASN_STRUCT_FREE(asn_DEF_NR_SIB2, SI_info->sib2); asn1cFreeStruc(asn_DEF_NR_SIB6, SI_info->sib6);
SI_info->sib2 = NULL; asn1cFreeStruc(asn_DEF_NR_SIB7, SI_info->sib7);
} asn1cFreeStruc(asn_DEF_NR_SIB8, SI_info->sib8);
if(SI_info->sib3) { asn1cFreeStruc(asn_DEF_NR_SIB9, SI_info->sib9);
ASN_STRUCT_FREE(asn_DEF_NR_SIB3, SI_info->sib3); asn1cFreeStruc(asn_DEF_NR_SIB10_r16, SI_info->sib10);
SI_info->sib3 = NULL; asn1cFreeStruc(asn_DEF_NR_SIB11_r16, SI_info->sib11);
} asn1cFreeStruc(asn_DEF_NR_SIB12_r16, SI_info->sib12);
if(SI_info->sib4) { asn1cFreeStruc(asn_DEF_NR_SIB13_r16, SI_info->sib13);
ASN_STRUCT_FREE(asn_DEF_NR_SIB4, SI_info->sib4); asn1cFreeStruc(asn_DEF_NR_SIB14_r16, SI_info->sib14);
SI_info->sib4 = NULL;
}
if(SI_info->sib5) {
ASN_STRUCT_FREE(asn_DEF_NR_SIB5, SI_info->sib5);
SI_info->sib5 = NULL;
}
if(SI_info->sib6) {
ASN_STRUCT_FREE(asn_DEF_NR_SIB6, SI_info->sib6);
SI_info->sib6 = NULL;
}
if(SI_info->sib7) {
ASN_STRUCT_FREE(asn_DEF_NR_SIB7, SI_info->sib7);
SI_info->sib7 = NULL;
}
if(SI_info->sib8) {
ASN_STRUCT_FREE(asn_DEF_NR_SIB8, SI_info->sib8);
SI_info->sib8 = NULL;
}
if(SI_info->sib9) {
ASN_STRUCT_FREE(asn_DEF_NR_SIB9, SI_info->sib9);
SI_info->sib9 = NULL;
}
if(SI_info->sib10) {
ASN_STRUCT_FREE(asn_DEF_NR_SIB10_r16, SI_info->sib10);
SI_info->sib10 = NULL;
}
if(SI_info->sib11) {
ASN_STRUCT_FREE(asn_DEF_NR_SIB11_r16, SI_info->sib11);
SI_info->sib11 = NULL;
}
if(SI_info->sib12) {
ASN_STRUCT_FREE(asn_DEF_NR_SIB12_r16, SI_info->sib12);
SI_info->sib12 = NULL;
}
if(SI_info->sib13) {
ASN_STRUCT_FREE(asn_DEF_NR_SIB13_r16, SI_info->sib13);
SI_info->sib13 = NULL;
}
if(SI_info->sib14) {
ASN_STRUCT_FREE(asn_DEF_NR_SIB14_r16, SI_info->sib14);
SI_info->sib14 = NULL;
}
} }
// reset MAC // reset MAC
......
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