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.
diff --git a/openbsc/src/e1_input.c b/openbsc/src/e1_input.c
index 2d0c134..7531755 100644
--- a/openbsc/src/e1_input.c
+++ b/openbsc/src/e1_input.c
@@ -370,10 +370,6 @@
if (ts->type != E1INP_TS_TYPE_SIGN)
return NULL;
- if (!tall_sigl_ctx)
- tall_sigl_ctx = talloc_named_const(tall_bsc_ctx, 1,
- "e1inp_sign_link");
-
link = talloc_zero(tall_sigl_ctx, struct e1inp_sign_link);
if (!link)
return NULL;
@@ -505,3 +501,9 @@
return 0;
}
+
+static __attribute__((constructor)) void on_dso_load_e1_inp(void)
+{
+ tall_sigl_ctx = talloc_named_const(tall_bsc_ctx, 1,
+ "e1inp_sign_link");
+}