pespin has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmo-sigtran/+/38729?usp=email )


Change subject: route_table: Split allocation code to its own function
......................................................................

route_table: Split allocation code to its own function

Change-Id: Id081d6de14be84b05ed38f3f8211ba91e675cff0
---
M src/osmo_ss7_route_table.c
1 file changed, 19 insertions(+), 8 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmo-sigtran 
refs/changes/29/38729/1

diff --git a/src/osmo_ss7_route_table.c b/src/osmo_ss7_route_table.c
index 4ab4594..910633b 100644
--- a/src/osmo_ss7_route_table.c
+++ b/src/osmo_ss7_route_table.c
@@ -32,6 +32,23 @@
  * SS7 Route Tables
  ***********************************************************************/

+static struct osmo_ss7_route_table *ss7_route_table_alloc(struct 
osmo_ss7_instance *inst, const char *name)
+{
+       struct osmo_ss7_route_table *rtbl;
+
+       OSMO_ASSERT(name);
+       LOGSS7(inst, LOGL_INFO, "Creating Route Table %s\n", name);
+
+       rtbl = talloc_zero(inst, struct osmo_ss7_route_table);
+       OSMO_ASSERT(rtbl);
+
+       rtbl->inst = inst;
+       rtbl->cfg.name = talloc_strdup(rtbl, name);
+       INIT_LLIST_HEAD(&rtbl->routes);
+       llist_add_tail(&rtbl->list, &inst->rtable_list);
+       return rtbl;
+}
+
 struct osmo_ss7_route_table *
 ss7_route_table_find(struct osmo_ss7_instance *inst, const char *name)
 {
@@ -51,14 +68,8 @@

        OSMO_ASSERT(ss7_initialized);
        rtbl = ss7_route_table_find(inst, name);
-       if (!rtbl) {
-               LOGSS7(inst, LOGL_INFO, "Creating Route Table %s\n", name);
-               rtbl = talloc_zero(inst, struct osmo_ss7_route_table);
-               rtbl->inst = inst;
-               rtbl->cfg.name = talloc_strdup(rtbl, name);
-               INIT_LLIST_HEAD(&rtbl->routes);
-               llist_add_tail(&rtbl->list, &inst->rtable_list);
-       }
+       if (!rtbl)
+               rtbl = ss7_route_table_alloc(inst, name);
        return rtbl;
 }


--
To view, visit https://gerrit.osmocom.org/c/libosmo-sigtran/+/38729?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: libosmo-sigtran
Gerrit-Branch: master
Gerrit-Change-Id: Id081d6de14be84b05ed38f3f8211ba91e675cff0
Gerrit-Change-Number: 38729
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <[email protected]>

Reply via email to