]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: use unique_ptr unstable_bits_t in SimpleLock 11635/head
authorPatrick Donnelly <pdonnell@redhat.com>
Mon, 24 Oct 2016 20:35:09 +0000 (16:35 -0400)
committerPatrick Donnelly <pdonnell@redhat.com>
Wed, 23 Nov 2016 00:25:21 +0000 (19:25 -0500)
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
src/mds/SimpleLock.h

index 736fab5cb4c93c97d2f3c274de3795dfb5f96759..3b62f55b437cb2d208b996007ebb06c50afb1512 100644 (file)
@@ -192,18 +192,17 @@ private:
                        excl_client(-1) {}
   };
 
-  mutable unstable_bits_t *_unstable;
+  mutable std::unique_ptr<unstable_bits_t> _unstable;
 
   bool have_more() const { return _unstable ? true : false; }
   unstable_bits_t *more() const {
     if (!_unstable)
-      _unstable = new unstable_bits_t;
-    return _unstable;
+      _unstable.reset(new unstable_bits_t);
+    return _unstable.get();
   }
   void try_clear_more() {
     if (_unstable && _unstable->empty()) {
-      delete _unstable;
-      _unstable = NULL;
+      _unstable.reset();
     }
   }
 
@@ -223,12 +222,9 @@ public:
     parent(o), 
     state(LOCK_SYNC),
     num_rdlock(0),
-    num_client_lease(0),
-    _unstable(NULL)
+    num_client_lease(0)
   {}
-  virtual ~SimpleLock() {
-    delete _unstable;
-  }
+  virtual ~SimpleLock() {}
 
   virtual bool is_scatterlock() const {
     return false;