pespin has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-sigtran/+/38663?usp=email )
Change subject: sigtran: Split osmo_ss7_instance allocation into its own function ......................................................................
sigtran: Split osmo_ss7_instance allocation into its own function
Change-Id: I38f9f19bb43d29999c4a7ba1a537403d1d58e880 --- M src/osmo_ss7.c 1 file changed, 19 insertions(+), 12 deletions(-)
Approvals: fixeria: Looks good to me, approved Jenkins Builder: Verified laforge: Looks good to me, but someone else must approve
diff --git a/src/osmo_ss7.c b/src/osmo_ss7.c index 65fff7c..c1de76a 100644 --- a/src/osmo_ss7.c +++ b/src/osmo_ss7.c @@ -315,21 +315,11 @@ return NULL; }
-/*! \brief Find or create a SS7 Instance - * \param[in] ctx talloc allocation context to use for allocations - * \param[in] id ID of SS7 Instance - * \returns \ref osmo_ss7_instance on success; NULL on error */ -struct osmo_ss7_instance * -osmo_ss7_instance_find_or_create(void *ctx, uint32_t id) +static struct osmo_ss7_instance * +ss7_instance_alloc(void *ctx, uint32_t id) { struct osmo_ss7_instance *inst;
- OSMO_ASSERT(ss7_initialized); - - inst = osmo_ss7_instance_find(id); - if (inst) - return inst; - inst = talloc_zero(ctx, struct osmo_ss7_instance); if (!inst) return NULL; @@ -360,6 +350,23 @@ return inst; }
+/*! \brief Find or create a SS7 Instance + * \param[in] ctx talloc allocation context to use for allocations + * \param[in] id ID of SS7 Instance + * \returns \ref osmo_ss7_instance on success; NULL on error */ +struct osmo_ss7_instance * +osmo_ss7_instance_find_or_create(void *ctx, uint32_t id) +{ + struct osmo_ss7_instance *inst; + + OSMO_ASSERT(ss7_initialized); + + inst = osmo_ss7_instance_find(id); + if (!inst) + inst = ss7_instance_alloc(ctx, id); + return inst; +} + /*! \brief Destroy a SS7 Instance * \param[in] inst SS7 Instance to be destroyed */ void osmo_ss7_instance_destroy(struct osmo_ss7_instance *inst)