bl.last_p = bl.begin();
}
+ void buffer::list::claim_append_piecewise(list& bl)
+ {
+ // steal the other guy's buffers
+ for (std::list<buffer::ptr>::const_iterator i = bl.buffers().begin();
+ i != bl.buffers().end(); i++) {
+ append(*i, 0, i->length());
+ }
+ bl.clear();
+ }
+
void buffer::list::copy(unsigned off, unsigned len, char *dest) const
{
if (off + len > length())
void claim(list& bl, unsigned int flags = CLAIM_DEFAULT);
void claim_append(list& bl, unsigned int flags = CLAIM_DEFAULT);
void claim_prepend(list& bl, unsigned int flags = CLAIM_DEFAULT);
+ // only for bl is bufferlist::page_aligned_appender
+ void claim_append_piecewise(list& bl);
// clone non-shareable buffers (make shareable)
void make_shareable() {
EXPECT_EQ((unsigned)0, from.length());
}
+TEST(BufferList, claim_append_piecewise) {
+ bufferlist bl, t, dst;
+ auto a = bl.get_page_aligned_appender(4);
+ for (uint32_t i = 0; i < (CEPH_PAGE_SIZE + CEPH_PAGE_SIZE - 1333); i++)
+ a.append("x", 1);
+ a.flush();
+ const char *p = bl.c_str();
+ t.claim_append(bl);
+
+ for (uint32_t i = 0; i < (CEPH_PAGE_SIZE + 1333); i++)
+ a.append("x", 1);
+ a.flush();
+ t.claim_append(bl);
+
+ EXPECT_FALSE(t.is_aligned_size_and_memory(CEPH_PAGE_SIZE, CEPH_PAGE_SIZE));
+ dst.claim_append_piecewise(t);
+ EXPECT_TRUE(dst.is_aligned_size_and_memory(CEPH_PAGE_SIZE, CEPH_PAGE_SIZE));
+ const char *p1 = dst.c_str();
+ EXPECT_TRUE(p == p1);
+}
+
TEST(BufferList, begin) {
bufferlist bl;
bl.append("ABC");