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/signal.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'openbsc/src/signal.c') diff --git a/openbsc/src/signal.c b/openbsc/src/signal.c index 41352fb1a..bf5671ee1 100644 --- a/openbsc/src/signal.c +++ b/openbsc/src/signal.c @@ -39,9 +39,6 @@ int register_signal_handler(unsigned int subsys, signal_cbfn *cbfn, void *data) { struct signal_handler *sig_data; - if (!tall_sigh_ctx) - tall_sigh_ctx = talloc_named_const(NULL, 1, "signal_handler"); - sig_data = talloc(tall_sigh_ctx, struct signal_handler); if (!sig_data) return -ENOMEM; @@ -84,3 +81,8 @@ void dispatch_signal(unsigned int subsys, unsigned int signal, void *signal_data (*handler->cbfn)(subsys, signal, handler->data, signal_data); } } + +static __attribute__((constructor)) void on_dso_load_signal(void) +{ + tall_sigh_ctx = talloc_named_const(NULL, 1, "signal_handler"); +} -- cgit v1.2.3