diff options
author | Daniel Willmann <dwillmann@sysmocom.de> | 2015-12-17 17:56:56 +0100 |
---|---|---|
committer | Daniel Willmann <dwillmann@sysmocom.de> | 2015-12-17 17:56:56 +0100 |
commit | 59d17d8961df96ff7cb22338e2af314a83ba12ab (patch) | |
tree | e9dfba5f00c5e9489fb0a2fa9c7cd5ad5b769327 /src | |
parent | 6637a289da9267c021497112d420ff0665507f50 (diff) |
hnbap: Free ASN.1 components after they are no longer needed
Diffstat (limited to 'src')
-rw-r--r-- | src/hnbap_common.c | 23 | ||||
-rw-r--r-- | src/hnbgw_hnbap.c | 4 |
2 files changed, 20 insertions, 7 deletions
diff --git a/src/hnbap_common.c b/src/hnbap_common.c index 0bb08fe..d72ca3e 100644 --- a/src/hnbap_common.c +++ b/src/hnbap_common.c @@ -141,7 +141,7 @@ struct msgb *hnbap_generate_initiating_message( Criticality_t criticality, asn_TYPE_descriptor_t * td, void *sptr) { - + struct msgb *msg; HNBAP_PDU_t pdu; int rc; @@ -156,7 +156,10 @@ struct msgb *hnbap_generate_initiating_message( return NULL; } - return _hnbap_gen_msg(&pdu); + msg = _hnbap_gen_msg(&pdu); + ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_HNBAP_PDU, &pdu); + + return msg; } struct msgb *hnbap_generate_successful_outcome( @@ -165,7 +168,7 @@ struct msgb *hnbap_generate_successful_outcome( asn_TYPE_descriptor_t * td, void *sptr) { - + struct msgb *msg; HNBAP_PDU_t pdu; int rc; @@ -180,7 +183,10 @@ struct msgb *hnbap_generate_successful_outcome( return NULL; } - return _hnbap_gen_msg(&pdu); + msg = _hnbap_gen_msg(&pdu); + ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_HNBAP_PDU, &pdu); + + return msg; } struct msgb *hnbap_generate_unsuccessful_outcome( @@ -189,7 +195,7 @@ struct msgb *hnbap_generate_unsuccessful_outcome( asn_TYPE_descriptor_t * td, void *sptr) { - + struct msgb *msg; HNBAP_PDU_t pdu; int rc; @@ -204,7 +210,10 @@ struct msgb *hnbap_generate_unsuccessful_outcome( return NULL; } - return _hnbap_gen_msg(&pdu); + msg = _hnbap_gen_msg(&pdu); + ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_HNBAP_PDU, &pdu); + + return msg; } IE_t *hnbap_new_ie(ProtocolIE_ID_t id, @@ -214,7 +223,7 @@ IE_t *hnbap_new_ie(ProtocolIE_ID_t id, IE_t *buff; - if ((buff = malloc(sizeof(IE_t))) == NULL) { + if ((buff = MALLOC(sizeof(IE_t))) == NULL) { // Possible error on malloc return NULL; } diff --git a/src/hnbgw_hnbap.c b/src/hnbgw_hnbap.c index 9378c7a..219169a 100644 --- a/src/hnbgw_hnbap.c +++ b/src/hnbgw_hnbap.c @@ -69,6 +69,8 @@ static int hnbgw_tx_hnb_register_acc(struct hnb_context *ctx) &asn_DEF_HNBRegisterAccept, &accept_out); + ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_HNBRegisterAccept, &accept_out); + return hnbgw_hnbap_tx(ctx, msg); } @@ -294,6 +296,8 @@ int hnbgw_hnbap_rx(struct hnb_context *hnb, struct msgb *msg) rc = _hnbgw_hnbap_rx(hnb, pdu); + ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_HNBAP_PDU, pdu); + return rc; } |