MCPcopy Create free account
hub / github.com/arvidn/libtorrent / copy_buffer

Method copy_buffer

src/stack_allocator.cpp:107–118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105 }
106
107 allocation_slot stack_allocator::copy_buffer(span<char const> buf)
108 {
109 auto const ret = m_storage.size();
110 auto const size = numeric_cast<std::size_t>(buf.size());
111 if (size < 1) return {};
112
113 if (std::numeric_limits<int>::max() - size <= ret)
114 return {};
115 m_storage.resize(ret + size);
116 std::memcpy(&m_storage[ret], buf.data(), numeric_cast<std::size_t>(size));
117 return allocation_slot(ret);
118 }
119
120 allocation_slot stack_allocator::allocate(int const bytes)
121 {

Callers 4

TORRENT_TESTFunction · 0.80
dht_pkt_alertMethod · 0.80
picker_log_alertMethod · 0.80

Calls 5

maxFunction · 0.85
allocation_slotClass · 0.85
sizeMethod · 0.45
resizeMethod · 0.45
dataMethod · 0.45

Tested by 1

TORRENT_TESTFunction · 0.64