aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2021-01-18 12:57:32 +0100
committerPau Espin Pedrol <pespin@sysmocom.de>2021-01-19 16:28:13 +0100
commit289f90048b04f1a6741ea948cb00d78c07346108 (patch)
treebaa1ec52d291c8eca3927fea01a3f34a938a8765
parent0ece97d718beace7a02b1e24bd78cbec22e252c8 (diff)
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
-rw-r--r--src/bts.cpp77
1 files changed, 34 insertions, 43 deletions
diff --git a/src/bts.cpp b/src/bts.cpp
index 92cbca50..0e08091c 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -192,8 +192,40 @@ static const struct osmo_stat_item_group_desc bts_statg_desc = {
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 @@ static void bts_init(struct gprs_rlcmac_bts *bts, struct gprs_pcu *pcu)
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 @@ GprsMs *bts_alloc_ms(struct gprs_rlcmac_bts* bts, uint8_t ms_class, uint8_t egpr
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;