]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
buffer: implement a contents_equal function on bufferlists
authorGreg Farnum <gregory.farnum@dreamhost.com>
Thu, 22 Mar 2012 00:27:09 +0000 (17:27 -0700)
committerGreg Farnum <gregory.farnum@dreamhost.com>
Tue, 3 Apr 2012 20:11:29 +0000 (13:11 -0700)
Signed-off-by: Greg Farnum <gregory.farnum@dreamhost.com>
src/common/buffer.cc
src/include/buffer.h

index 893d8a7382f79ac93a4cdd0eb0070f48ac904bad..a6ad8c0d736ab2de1f72a2b8c4ea64837daa6aee 100644 (file)
@@ -611,6 +611,21 @@ bool buffer_track_alloc = get_env_bool("CEPH_BUFFER_TRACK");
     other.last_p = other.begin();
   }
 
+  bool buffer::list::contents_equal(ceph::buffer::list& other)
+  {
+    if (length() != other.length())
+      return false;
+    bufferlist::iterator me = begin();
+    bufferlist::iterator him = other.begin();
+    while (!me.end()) {
+      if (*me != *him)
+        return false;
+      ++me;
+      ++him;
+    }
+    return true;
+  }
+
   bool buffer::list::is_page_aligned() const
   {
     for (std::list<ptr>::const_iterator it = _buffers.begin();
index 12dec986ea951e460faa1de5dbc96be4404720cc..65c101f6f966f977f6d06a5b25cb77ad5ea8f734 100644 (file)
@@ -325,6 +325,7 @@ public:
 #endif
       return _len;
     }
+    bool contents_equal(buffer::list& other);
 
     bool is_page_aligned() const;
     bool is_n_page_sized() const;