]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw/dbstore: Cleanup - use unique_ptr instead of new/delete in DBZone
authorOshrey Avraham <oshrey16@gmail.com>
Sun, 13 Oct 2024 16:27:43 +0000 (19:27 +0300)
committerOshrey Avraham <oshrey16@gmail.com>
Sun, 13 Oct 2024 16:27:43 +0000 (19:27 +0300)
This commit refactors the 'DBZone' class to utilize 'std::unique_ptr' instead of raw pointers and manual memory management with 'new' and 'delete'.

Fixes: https://tracker.ceph.com/issues/57501
Signed-off-by: Oshrey Avraham <oshrey16@gmail.com>
src/rgw/rgw_sal_dbstore.h

index 107ba735a63acaa4f09b574d93211fd41789bf83..b54249df0319d20b09e01bdda22dd27cfb2aafd1 100644 (file)
@@ -268,22 +268,22 @@ protected:
   class DBZone : public StoreZone {
     protected:
       DBStore* store;
-      RGWRealm *realm{nullptr};
-      DBZoneGroup *zonegroup{nullptr};
-      RGWZone *zone_public_config{nullptr}; /* external zone params, e.g., entrypoints, log flags, etc. */
-      RGWZoneParams *zone_params{nullptr}; /* internal zone params, e.g., rados pools */
-      RGWPeriod *current_period{nullptr};
+       std::unique_ptr<RGWRealm> realm;
+       std::unique_ptr<DBZoneGroup> zonegroup;
+       std::unique_ptr<RGWZone> zone_public_config; /* external zone params, e.g., entrypoints, log flags, etc. */
+       std::unique_ptr<RGWZoneParams> zone_params; /* internal zone params, e.g., rados pools */
+       std::unique_ptr<RGWPeriod> current_period;
 
     public:
       DBZone(DBStore* _store) : store(_store) {
-       realm = new RGWRealm();
+       realm = std::make_unique<RGWRealm>();
        std::unique_ptr<RGWZoneGroup> rzg = std::make_unique<RGWZoneGroup>("default", "default");
        rzg->api_name = "default";
        rzg->is_master = true;
-        zonegroup = new DBZoneGroup(store, std::move(rzg));
-        zone_public_config = new RGWZone();
-        zone_params = new RGWZoneParams();
-        current_period = new RGWPeriod();
+       zonegroup = std::make_unique<DBZoneGroup>(store, std::move(rzg));
+       zone_public_config = std::make_unique<RGWZone>();
+       zone_params = std::make_unique<RGWZoneParams>();
+       current_period = std::make_unique<RGWPeriod>();
 
         // XXX: only default and STANDARD supported for now
         RGWZonePlacementInfo info;
@@ -292,13 +292,7 @@ protected:
         info.storage_classes = sc;
         zone_params->placement_pools["default"] = info;
       }
-      ~DBZone() {
-       delete realm;
-       delete zonegroup;
-       delete zone_public_config;
-       delete zone_params;
-       delete current_period;
-      }
+       ~DBZone() = default;
 
       virtual std::unique_ptr<Zone> clone() override {
        return std::make_unique<DBZone>(store);