Current callers expect a deep copy; be explicit about it.
Signed-off-by: Sage Weil <sage@redhat.com>
__u16 len;
::decode(len, bl);
bufferptr tmp;
- bl.copy(len, tmp);
+ bl.copy_deep(len, tmp);
if (_set_secret(type, tmp) < 0)
throw buffer::malformed_input("malformed secret");
}
}
template<bool is_const>
- void buffer::list::iterator_impl<is_const>::copy(unsigned len, ptr &dest)
+ void buffer::list::iterator_impl<is_const>::copy_deep(unsigned len, ptr &dest)
{
+ if (p == ls->end())
+ throw end_of_buffer();
+ assert(p->length() > 0);
dest = create(len);
copy(len, dest.c_str());
}
return buffer::list::iterator_impl<false>::copy(len, dest);
}
- void buffer::list::iterator::copy(unsigned len, ptr &dest)
+ void buffer::list::iterator::copy_deep(unsigned len, ptr &dest)
{
- buffer::list::iterator_impl<false>::copy(len, dest);
+ buffer::list::iterator_impl<false>::copy_deep(len, dest);
+ }
+
+ void buffer::list::iterator::copy_shallow(unsigned len, ptr &dest)
+ {
+ buffer::list::iterator_impl<false>::copy_shallow(len, dest);
}
void buffer::list::iterator::copy(unsigned len, list &dest)
// copy data out.
// note that these all _append_ to dest!
void copy(unsigned len, char *dest);
- void copy(unsigned len, ptr &dest);
+ void copy_deep(unsigned len, ptr &dest);
void copy(unsigned len, list &dest);
void copy(unsigned len, std::string &dest);
void copy_all(list &dest);
// copy data out
void copy(unsigned len, char *dest);
- void copy(unsigned len, ptr &dest);
+ void copy_deep(unsigned len, ptr &dest);
void copy(unsigned len, list &dest);
void copy(unsigned len, std::string &dest);
void copy_all(list &dest);
inline void small_decode_buf_lowz(T& bp, bufferlist::iterator& p) {
size_t l;
small_decode_varint_lowz(l, p);
- p.copy(l, bp);
+ p.copy_deep(l, bp);
}
// STL containers
EXPECT_EQ(0, ::memcmp(copy, expected, 3));
}
//
- // void buffer::list::iterator::copy(unsigned len, ptr &dest)
+ // void buffer::list::iterator::copy_deep(unsigned len, ptr &dest)
//
{
bufferptr ptr;
bufferlist::iterator i(&bl);
- i.copy(2, ptr);
+ i.copy_deep(2, ptr);
EXPECT_EQ((unsigned)2, ptr.length());
EXPECT_EQ('A', ptr[0]);
EXPECT_EQ('B', ptr[1]);
if (src.length() > 0) {
bufferlist::iterator iter = src.begin();
buffer::ptr ptr;
- iter.copy(src.length(), ptr);
+ iter.copy_deep(src.length(), ptr);
dest->append(ptr);
}
}