Calculate crc from an iterator position.
Signed-off-by: Sage Weil <sage@redhat.com>
return l;
}
+ template<bool is_const>
+ uint32_t buffer::list::iterator_impl<is_const>::crc32c(
+ size_t length, uint32_t crc)
+ {
+ while (length > 0) {
+ const char *p;
+ size_t l = get_ptr_and_advance(length, &p);
+ crc = ceph_crc32c(crc, (unsigned char*)p, l);
+ length -= l;
+ }
+ return crc;
+ }
+
// explicitly instantiate only the iterator types we need, so we can hide the
// details in this compilation unit without introducing unnecessary link time
// dependencies.
// and advance the iterator by that amount.
size_t get_ptr_and_advance(size_t want, const char **p);
+ /// calculate crc from iterator position
+ uint32_t crc32c(size_t length, uint32_t crc);
+
friend bool operator==(const iterator_impl& lhs,
const iterator_impl& rhs) {
return &lhs.get_bl() == &rhs.get_bl() && lhs.get_off() == rhs.get_off();