aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/gsm_04_11.c
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2009-07-28 00:41:45 +0200
committerHarald Welte <laforge@gnumonks.org>2009-07-28 00:41:45 +0200
commit7bfc26749662e3a3227037cce4a24748343b50be (patch)
tree2bd0ad79d43b2e72407792d30cac97e5fb8f825d /openbsc/src/gsm_04_11.c
parentb49248bf48b0856e3b156810681ea3fca44c728a (diff)
move allocation of talloc contexts into link-time constructor
This is much more optimal than checking if the context exists every time we allocate the respective object.
Diffstat (limited to 'openbsc/src/gsm_04_11.c')
-rw-r--r--openbsc/src/gsm_04_11.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/openbsc/src/gsm_04_11.c b/openbsc/src/gsm_04_11.c
index 8db402b33..9218783ff 100644
--- a/openbsc/src/gsm_04_11.c
+++ b/openbsc/src/gsm_04_11.c
@@ -162,19 +162,11 @@ 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;
- 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));
- 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) {
talloc_free(sms);
@@ -513,3 +505,9 @@ int gsm0411_send_sms(struct gsm_lchan *lchan, struct sms_deliver *sms)
return gsm0411_sendmsg(msg);
}
+
+static __attribute__((constructor)) void on_dso_load_sms(void)
+{
+ tall_sms_ctx = talloc_named_const(tall_bsc_ctx, 1, "sms_submit");
+ tall_gsms_ctx = talloc_named_const(tall_bsc_ctx, 1, "sms");
+}