Change in osmo-pcu[master]: bts: combine bts_{init, cleanup} into consturctor/destructor methods

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/gerrit-log@lists.osmocom.org/.

pespin gerrit-no-reply at lists.osmocom.org
Tue Jan 19 16:40:07 UTC 2021


pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-pcu/+/22277 )

Change subject: bts: combine bts_{init,cleanup} into consturctor/destructor methods
......................................................................

bts: combine bts_{init,cleanup} into consturctor/destructor methods

The bts_init/cleanup functions were kept during the C and C++ structure
merge process to make the patch simpler. It's not needed anymore,
let's move all the destructor logic into one function and keep that
together.

Change-Id: I73a9457d5c92f62261561ef6afe392953576aec4
---
M src/bts.cpp
1 file changed, 34 insertions(+), 43 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, but someone else must approve
  osmith: Looks good to me, approved



diff --git a/src/bts.cpp b/src/bts.cpp
index 92cbca5..0e08091 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -192,8 +192,40 @@
 	bts_stat_item_description,
 };
 
-static void bts_init(struct gprs_rlcmac_bts *bts, struct gprs_pcu *pcu)
+static int bts_talloc_destructor(struct gprs_rlcmac_bts* bts)
 {
+	/* this can cause counter updates and must not be left to the
+	 * m_ms_store's destructor */
+	bts->ms_store->cleanup();
+	delete bts->ms_store;
+	delete bts->sba;
+	delete bts->pollController;
+
+	if (bts->ratectrs) {
+		rate_ctr_group_free(bts->ratectrs);
+		bts->ratectrs = NULL;
+	}
+
+	if (bts->statg) {
+		osmo_stat_item_group_free(bts->statg);
+		bts->statg = NULL;
+	}
+
+	if (bts->app_info) {
+		msgb_free(bts->app_info);
+		bts->app_info = NULL;
+	}
+	return 0;
+}
+
+struct gprs_rlcmac_bts* bts_alloc(struct gprs_pcu *pcu)
+{
+	struct gprs_rlcmac_bts* bts;
+	bts = talloc_zero(pcu, struct gprs_rlcmac_bts);
+	if (!bts)
+		return bts;
+	talloc_set_destructor(bts, bts_talloc_destructor);
+
 	bts->pcu = pcu;
 
 	bts->pollController = new PollController(*bts);
@@ -247,31 +279,8 @@
 
 	bts->statg = osmo_stat_item_group_alloc(tall_pcu_ctx, &bts_statg_desc, 0);
 	OSMO_ASSERT(bts->statg);
-}
 
-static void bts_cleanup(gprs_rlcmac_bts *bts)
-{
-	/* this can cause counter updates and must not be left to the
-	 * m_ms_store's destructor */
-	bts->ms_store->cleanup();
-	delete bts->ms_store;
-	delete bts->sba;
-	delete bts->pollController;
-
-	if (bts->ratectrs) {
-		rate_ctr_group_free(bts->ratectrs);
-		bts->ratectrs = NULL;
-	}
-
-	if (bts->statg) {
-		osmo_stat_item_group_free(bts->statg);
-		bts->statg = NULL;
-	}
-
-	if (bts->app_info) {
-		msgb_free(bts->app_info);
-		bts->app_info = NULL;
-	}
+	return bts;
 }
 
 void bts_set_current_frame_number(struct gprs_rlcmac_bts *bts, int fn)
@@ -1057,24 +1066,6 @@
 	return ms;
 }
 
-
-static int bts_talloc_destructor(struct gprs_rlcmac_bts* bts)
-{
-	bts_cleanup(bts);
-	return 0;
-}
-
-struct gprs_rlcmac_bts* bts_alloc(struct gprs_pcu *pcu)
-{
-	struct gprs_rlcmac_bts* bts;
-	bts = talloc_zero(pcu, struct gprs_rlcmac_bts);
-	if (!bts)
-		return bts;
-	talloc_set_destructor(bts, bts_talloc_destructor);
-	bts_init(bts, pcu);
-	return bts;
-}
-
 struct SBAController *bts_sba(struct gprs_rlcmac_bts *bts)
 {
 	return bts->sba;

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-pcu/+/22277
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: I73a9457d5c92f62261561ef6afe392953576aec4
Gerrit-Change-Number: 22277
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: osmith <osmith at sysmocom.de>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210119/ca6b5e7b/attachment.htm>


More information about the gerrit-log mailing list