From 7bfc26749662e3a3227037cce4a24748343b50be Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Tue, 28 Jul 2009 00:41:45 +0200 Subject: 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. --- openbsc/src/subchan_demux.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'openbsc/src/subchan_demux.c') diff --git a/openbsc/src/subchan_demux.c b/openbsc/src/subchan_demux.c index ccd4fadc6..368b9853c 100644 --- a/openbsc/src/subchan_demux.c +++ b/openbsc/src/subchan_demux.c @@ -312,9 +312,6 @@ int subchan_mux_init(struct subch_mux *mx) { int i; - if (!tall_tqe_ctx) - tall_tqe_ctx = talloc_named_const(tall_bsc_ctx, 1, - "subch_txq_entry"); memset(mx, 0, sizeof(*mx)); for (i = 0; i < NR_SUBCH; i++) { struct mux_subch *sch = &mx->subch[i]; @@ -323,3 +320,9 @@ int subchan_mux_init(struct subch_mux *mx) return 0; } + +static __attribute__((constructor)) void on_dso_load_ss_demux(void) +{ + tall_tqe_ctx = talloc_named_const(tall_bsc_ctx, 1, + "subch_txq_entry"); +} -- cgit v1.2.3