aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/gsm_04_11.c
diff options
context:
space:
mode:
Diffstat (limited to 'openbsc/src/gsm_04_11.c')
-rw-r--r--openbsc/src/gsm_04_11.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/openbsc/src/gsm_04_11.c b/openbsc/src/gsm_04_11.c
index 3d5820d66..1b622b12b 100644
--- a/openbsc/src/gsm_04_11.c
+++ b/openbsc/src/gsm_04_11.c
@@ -41,13 +41,18 @@
#include <openbsc/abis_rsl.h>
#include <openbsc/signal.h>
#include <openbsc/db.h>
+#include <openbsc/talloc.h>
#define GSM411_ALLOC_SIZE 1024
#define GSM411_ALLOC_HEADROOM 128
+static void *tall_sms_ctx;
+static void *tall_gsms_ctx;
+
struct msgb *gsm411_msgb_alloc(void)
{
- return msgb_alloc_headroom(GSM411_ALLOC_SIZE, GSM411_ALLOC_HEADROOM);
+ return msgb_alloc_headroom(GSM411_ALLOC_SIZE, GSM411_ALLOC_HEADROOM,
+ "GSM 04.11");
}
int gsm0411_sendmsg(struct msgb *msg)
@@ -139,8 +144,8 @@ static int gsm340_rx_sms_submit(struct msgb *msg, struct sms_submit *sms,
{
if (db_sms_store(gsms) != 0) {
DEBUGP(DSMS, "Failed to store SMS in Database\n");
- free(sms);
- free(gsms);
+ talloc_free(sms);
+ talloc_free(gsms);
return -EIO;
}
return 0;
@@ -156,14 +161,22 @@ static int gsm340_rx_tpdu(struct msgb *msg)
u_int8_t address_lv[12]; /* according to 03.40 / 9.1.2.5 */
int rc = 0;
- sms = malloc(sizeof(*sms));
+ if (!tall_sms_ctx)
+ tall_sms_ctx = talloc_named_const(tall_bsc_ctx, 1,
+ "sms_submit");
+
+ sms = talloc(tall_sms_ctx, struct sms_submit);
if (!sms)
return -ENOMEM;
memset(sms, 0, sizeof(*sms));
- gsms = malloc(sizeof(*gsms));
+ if (!tall_gsms_ctx)
+ tall_gsms_ctx = talloc_named_const(tall_bsc_ctx, 1,
+ "sms");
+
+ gsms = talloc(tall_gsms_ctx, struct gsm_sms);
if (!gsms) {
- free(sms);
+ talloc_free(sms);
return -ENOMEM;
}
memset(gsms, 0, sizeof(*gsms));
@@ -268,8 +281,8 @@ static int gsm340_rx_tpdu(struct msgb *msg)
}
out:
- free(gsms);
- free(sms);
+ talloc_free(gsms);
+ talloc_free(sms);
return rc;
}