]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: use unique_ptr bufferlist in inline_data_t
authorPatrick Donnelly <pdonnell@redhat.com>
Mon, 24 Oct 2016 15:51:50 +0000 (11:51 -0400)
committerPatrick Donnelly <pdonnell@redhat.com>
Wed, 23 Nov 2016 00:03:23 +0000 (19:03 -0500)
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
src/mds/mdstypes.h

index a384fbcda04bca1a2846148abfa540c954596db2..b3f4f14bf8abbce554b2e83abcac06503f3bf8a9 100644 (file)
@@ -415,29 +415,25 @@ inline bool operator==(const client_writeable_range_t& l,
 
 struct inline_data_t {
 private:
-  bufferlist *blp;
+  std::unique_ptr<bufferlist> blp;
 public:
   version_t version;
 
   void free_data() {
-    delete blp;
-    blp = NULL;
+    blp.reset();
   }
   bufferlist& get_data() {
     if (!blp)
-      blp = new bufferlist;
+      blp.reset(new bufferlist);
     return *blp;
   }
   size_t length() const { return blp ? blp->length() : 0; }
 
-  inline_data_t() : blp(0), version(1) {}
-  inline_data_t(const inline_data_t& o) : blp(0), version(o.version) {
+  inline_data_t() : version(1) {}
+  inline_data_t(const inline_data_t& o) : version(o.version) {
     if (o.blp)
       get_data() = *o.blp;
   }
-  ~inline_data_t() {
-    free_data();
-  }
   inline_data_t& operator=(const inline_data_t& o) {
     version = o.version;
     if (o.blp)
@@ -449,7 +445,7 @@ public:
   bool operator==(const inline_data_t& o) const {
    return length() == o.length() &&
          (length() == 0 ||
-          (*const_cast<bufferlist*>(blp) == *const_cast<bufferlist*>(o.blp)));
+          (*const_cast<bufferlist*>(blp.get()) == *const_cast<bufferlist*>(o.blp.get())));
   }
   bool operator!=(const inline_data_t& o) const {
     return !(*this == o);