[PATCH 3/5] libctrl: Avoid using external tall_bsc_ctx

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/OpenBSC@lists.osmocom.org/.

Harald Welte laforge at gnumonks.org
Wed Aug 20 18:15:08 UTC 2014


Instead of using one flat talloc context (and one that is specific to
openbsc), we should attach the objects to whatever parent context they
are being used in.
---
 src/ctrl/control_if.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/ctrl/control_if.c b/src/ctrl/control_if.c
index 7ce8bf6..a208071 100644
--- a/src/ctrl/control_if.c
+++ b/src/ctrl/control_if.c
@@ -96,7 +96,7 @@ struct ctrl_cmd *ctrl_cmd_trap(struct ctrl_cmd *cmd)
 {
 	struct ctrl_cmd *trap;
 
-	trap = ctrl_cmd_cpy(tall_bsc_ctx, cmd);
+	trap = ctrl_cmd_cpy(cmd, cmd);
 	if (!trap)
 		return NULL;
 
@@ -281,10 +281,10 @@ static uint64_t get_rate_ctr_value(const struct rate_ctr *ctr, int intv)
 	}
 }
 
-static char *get_all_rate_ctr_in_group(const struct rate_ctr_group *ctrg, int intv)
+static char *get_all_rate_ctr_in_group(void *ctx, const struct rate_ctr_group *ctrg, int intv)
 {
 	int i;
-	char *counters = talloc_strdup(tall_bsc_ctx, "");
+	char *counters = talloc_strdup(ctx, "");
 	if (!counters)
 		return NULL;
 
@@ -314,7 +314,7 @@ static int get_rate_ctr_group(const char *ctr_group, int intv, struct ctrl_cmd *
 		if (!ctrg)
 			break;
 
-		counters = get_all_rate_ctr_in_group(ctrg, intv);
+		counters = get_all_rate_ctr_in_group(cmd, ctrg, intv);
 		if (!counters)
 			goto oom;
 
@@ -340,7 +340,7 @@ static int get_rate_ctr_group_idx(const struct rate_ctr_group *ctrg, int intv, s
 {
 	char *counters;
 
-	counters = get_all_rate_ctr_in_group(ctrg, intv);
+	counters = get_all_rate_ctr_in_group(cmd, ctrg, intv);
 	if (!counters)
 		goto oom;
 
@@ -527,7 +527,7 @@ struct ctrl_handle *controlif_setup(struct gsm_network *gsmnet, uint16_t port,
 	int ret;
 	struct ctrl_handle *ctrl;
 
-	ctrl = talloc_zero(tall_bsc_ctx, struct ctrl_handle);
+	ctrl = talloc_zero(gsmnet, struct ctrl_handle);
 	if (!ctrl)
 		return NULL;
 
-- 
2.1.0.rc1





More information about the OpenBSC mailing list