aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/msgb.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/msgb.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/msgb.c')
-rw-r--r--openbsc/src/msgb.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/openbsc/src/msgb.c b/openbsc/src/msgb.c
index ae1334614..52edf2dcd 100644
--- a/openbsc/src/msgb.c
+++ b/openbsc/src/msgb.c
@@ -33,9 +33,6 @@ struct msgb *msgb_alloc(u_int16_t size, const char *name)
{
struct msgb *msg;
- if (!tall_msgb_ctx)
- tall_msgb_ctx = talloc_named_const(tall_bsc_ctx, 1, "msgb");
-
msg = _talloc_zero(tall_msgb_ctx, sizeof(*msg) + size, name);
if (!msg)
@@ -76,3 +73,8 @@ struct msgb *msgb_dequeue(struct llist_head *queue)
return llist_entry(lh, struct msgb, list);
}
+
+static __attribute__((constructor)) void on_dso_load_trau_msgb(void)
+{
+ tall_msgb_ctx = talloc_named_const(tall_bsc_ctx, 1, "msgb");
+}