aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/osmo-bsc_nat/bsc_ussd.c
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2019-05-01 22:30:26 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2019-05-16 17:19:42 +0200
commitc44cbbf839dcff3f7b83ca3a051854e52fe88e40 (patch)
tree5ec3794a6ddaaf8bc52ef6c0d031a38fc4098740 /openbsc/src/osmo-bsc_nat/bsc_ussd.c
parent7ab9a9eb50076e98cae0c978622d7be99d9d1b02 (diff)
nat: Allocate bsc_nat_parsed on the stack instead of heap
There's no real need to allocate it using talloc. Allocating it on the stack simplifies the code, avoids mem leaks and makes it faster. Change-Id: I66c44890952339f15131081e2f629a2824b6d3ba
Diffstat (limited to 'openbsc/src/osmo-bsc_nat/bsc_ussd.c')
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_ussd.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/openbsc/src/osmo-bsc_nat/bsc_ussd.c b/openbsc/src/osmo-bsc_nat/bsc_ussd.c
index dea18073f..d44b1b2fe 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_ussd.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_ussd.c
@@ -90,30 +90,27 @@ static void ussd_pong(struct bsc_nat_ussd_con *conn)
static int forward_sccp(struct bsc_nat *nat, struct msgb *msg)
{
struct nat_sccp_connection *con;
- struct bsc_nat_parsed *parsed;
+ struct bsc_nat_parsed parsed;
-
- parsed = bsc_nat_parse(msg);
- if (!parsed) {
+ if (bsc_nat_parse(msg, &parsed) < 0) {
LOGP(DNAT, LOGL_ERROR, "Can not parse msg from USSD.\n");
msgb_free(msg);
return -1;
}
- if (!parsed->dest_local_ref) {
+ if (!parsed.dest_local_ref) {
LOGP(DNAT, LOGL_ERROR, "No destination local reference.\n");
msgb_free(msg);
return -1;
}
- con = bsc_nat_find_con_by_bsc(nat, parsed->dest_local_ref);
+ con = bsc_nat_find_con_by_bsc(nat, parsed.dest_local_ref);
if (!con || !con->bsc) {
LOGP(DNAT, LOGL_ERROR, "No active connection found.\n");
msgb_free(msg);
return -1;
}
- talloc_free(parsed);
bsc_write_msg(&con->bsc->write_queue, msg);
return 0;
}