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/abis_nm.c b/openbsc/src/abis_nm.c
index 2b56479..dec4b29 100644
--- a/openbsc/src/abis_nm.c
+++ b/openbsc/src/abis_nm.c
@@ -2056,10 +2056,6 @@
FILE *swl;
int rc = 0;
- if (!tall_fle_ctx)
- tall_fle_ctx = talloc_named_const(tall_bsc_ctx, 1,
- "bs11_file_list_entry");
-
swl = fopen(bs11_sw->swl_fname, "r");
if (!swl)
return -ENODEV;
@@ -2373,3 +2369,10 @@
{
return __simple_cmd(bts, NM_MT_IPACC_RESTART);
}
+
+
+static __attribute__((constructor)) void on_dso_load_abis_nm(void)
+{
+ tall_fle_ctx = talloc_named_const(tall_bsc_ctx, 1,
+ "bs11_file_list_entry");
+}