buffer: add claim_prepend()

Steal another bufferlist's content and prepend it to our own.

Signed-off-by: Sage Weil <sage@inktank.com>
This commit is contained in:
Sage Weil 2012-10-02 14:30:27 -07:00
parent 827ad53aba
commit 36a2245d50
2 changed files with 9 additions and 0 deletions

View 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
{

View 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);