]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
buffer: add claim_prepend()
authorSage Weil <sage@inktank.com>
Tue, 2 Oct 2012 21:30:27 +0000 (14:30 -0700)
committerSage Weil <sage@inktank.com>
Mon, 15 Oct 2012 22:34:04 +0000 (15:34 -0700)
Steal another bufferlist's content and prepend it to our own.

Signed-off-by: Sage Weil <sage@inktank.com>
src/common/buffer.cc
src/include/buffer.h

index 60c36a6f728e42619394ce035c6f839ea7b3a516..b2d3ec6ed8c9b706a919c312d0e8fa265b0bf14d 100644 (file)
@@ -826,6 +826,14 @@ void buffer::list::rebuild_page_aligned()
     bl.last_p = bl.begin();
   }
 
+  void buffer::list::claim_prepend(list& bl)
+  {
+    // steal the other guy's buffers
+    _len += bl._len;
+    _buffers.splice( _buffers.begin(), bl._buffers );
+    bl._len = 0;
+    bl.last_p = bl.begin();
+  }
 
   void buffer::list::copy(unsigned off, unsigned len, char *dest) const
   {
index f063c7ca64bc2c721fdd01b9c2e3771f4d25bf09..4a9e96c6067702c7824124f3d1e92f82f7b56a78 100644 (file)
@@ -371,6 +371,7 @@ public:
     // sort-of-like-assignment-op
     void claim(list& bl);
     void claim_append(list& bl);
+    void claim_prepend(list& bl);
 
     iterator begin() {
       return iterator(this, 0);