buffer: implement ptr::end_c_str()

Signed-off-by: Sage Weil <sage@redhat.com>
This commit is contained in:
Sage Weil 2016-09-13 14:01:51 -04:00
parent 43d0554d01
commit 3bf531708c
2 changed files with 14 additions and 0 deletions

View File

@ -900,6 +900,18 @@ static simple_spinlock_t buffer_debug_lock = SIMPLE_SPINLOCK_INITIALIZER;
buffer_c_str_accesses.inc();
return _raw->get_data() + _off;
}
const char *buffer::ptr::end_c_str() const {
assert(_raw);
if (buffer_track_c_str)
buffer_c_str_accesses.inc();
return _raw->get_data() + _off + _len;
}
char *buffer::ptr::end_c_str() {
assert(_raw);
if (buffer_track_c_str)
buffer_c_str_accesses.inc();
return _raw->get_data() + _off + _len;
}
unsigned buffer::ptr::unused_tail_length() const
{

View File

@ -209,6 +209,8 @@ namespace buffer CEPH_BUFFER_API {
raw *get_raw() const { return _raw; }
const char *c_str() const;
char *c_str();
const char *end_c_str() const;
char *end_c_str();
unsigned length() const { return _len; }
unsigned offset() const { return _off; }
unsigned start() const { return _off; }