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/gsm_subscriber.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'openbsc/src/gsm_subscriber.c') diff --git a/openbsc/src/gsm_subscriber.c b/openbsc/src/gsm_subscriber.c index e89290623..748015693 100644 --- a/openbsc/src/gsm_subscriber.c +++ b/openbsc/src/gsm_subscriber.c @@ -103,10 +103,6 @@ struct gsm_subscriber *subscr_alloc(void) { struct gsm_subscriber *s; - if (!tall_subscr_ctx) - tall_subscr_ctx = talloc_named_const(tall_bsc_ctx, 1, - "subscriber"); - s = talloc(tall_subscr_ctx, struct gsm_subscriber); if (!s) return NULL; @@ -213,10 +209,6 @@ void subscr_get_channel(struct gsm_subscriber *subscr, { struct subscr_request *request; - if (!tall_sub_req_ctx) - tall_sub_req_ctx = talloc_named_const(tall_bsc_ctx, 1, - "subscr_request"); - request = talloc(tall_sub_req_ctx, struct subscr_request); if (!request) { if (cbfn) @@ -273,3 +265,11 @@ void subscr_put_channel(struct gsm_lchan *lchan) subscr_send_paging_request(lchan->subscr); } + +static __attribute__((constructor)) void on_dso_load_subscr(void) +{ + tall_subscr_ctx = talloc_named_const(tall_bsc_ctx, 1, "subscriber"); + + tall_sub_req_ctx = talloc_named_const(tall_bsc_ctx, 1, + "subscr_request"); +} -- cgit v1.2.3