MCPcopy Create free account
hub / github.com/ceph/ceph / obtain_contiguous_space

Method obtain_contiguous_space

src/common/buffer.cc:1383–1412  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1381 }
1382
1383 buffer::list::reserve_t buffer::list::obtain_contiguous_space(
1384 const unsigned len)
1385 {
1386 // note: if len < the normal append_buffer size it *might*
1387 // be better to allocate a normal-sized append_buffer and
1388 // use part of it. however, that optimizes for the case of
1389 // old-style types including new-style types. and in most
1390 // such cases, this won't be the very first thing encoded to
1391 // the list, so append_buffer will already be allocated.
1392 // OTOH if everything is new-style, we *should* allocate
1393 // only what we need and conserve memory.
1394 if (unlikely(get_append_buffer_unused_tail_length() < len)) {
1395 auto new_back = \
1396 buffer::ptr_node::create(buffer::create(len)).release();
1397 new_back->set_length(0); // unused, so far.
1398 _buffers.push_back(*new_back);
1399 _num += 1;
1400 _carriage = new_back;
1401 return { new_back->c_str(), &new_back->_len, &_len };
1402 } else {
1403 ceph_assert(!_buffers.empty());
1404 if (unlikely(_carriage != &_buffers.back())) {
1405 auto bptr = ptr_node::create(*_carriage, _carriage->length(), 0);
1406 _carriage = bptr.get();
1407 _buffers.push_back(*bptr.release());
1408 _num += 1;
1409 }
1410 return { _carriage->end_c_str(), &_carriage->_len, &_len };
1411 }
1412 }
1413
1414 void buffer::list::append(const ptr& bp)
1415 {

Callers 6

contiguous_appenderMethod · 0.80
appendMethod · 0.80
appendMethod · 0.80
contiguous_appenderMethod · 0.80
appendMethod · 0.80
appendMethod · 0.80

Calls 11

set_lengthMethod · 0.80
end_c_strMethod · 0.80
createFunction · 0.70
releaseMethod · 0.45
push_backMethod · 0.45
c_strMethod · 0.45
emptyMethod · 0.45
backMethod · 0.45
lengthMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected