This usage got introduced in
7c68bd931bf4acdcadfd3ef7462935ab8f1ff09c
and later reworked by
55099fb05b76ac7f4f72a41fa77ad9672711a93d.
It can be easily replaced with `ptr::iterator::get_ptr()` as:
1. the source `cache_bp` bases on `raw_static`:
```
void WriteLogEntry::init_cache_bp() {
ceph_assert(!this->cache_bp.have_raw());
cache_bp = buffer::ptr(buffer::create_static(this->write_bytes(),
(char*)this->cache_buffer));
}
```
2. which `clone_empty()` is implemented as follows:
```
class buffer::raw_static : public buffer::raw {
public:
MEMPOOL_CLASS_HELPERS();
raw_static(const char *d, unsigned l) : raw((char*)d, l) { }
~raw_static() override {}
raw* clone_empty() override {
return new buffer::raw_char(len);
}
};
```
Signed-off-by: Radosław Zarzyński <rzarzyns@redhat.com>
void WriteLogEntry::copy_cache_bl(bufferlist *out_bl) {
this->get_cache_bl();
// cache_bp is now initialized
- buffer::ptr cloned_bp(cache_bp.clone());
+ ceph_assert(cache_bp.length() == cache_bp.raw_length());
+ buffer::ptr cloned_bp = cache_bp.begin_deep().get_ptr(cache_bp.length());
out_bl->clear();
this->init_bl(cloned_bp, *out_bl);
}