MCPcopy Create free account
hub / github.com/chronoxor/FastBinaryEncoding / allocate

Method allocate

proto/fbe.cpp:348–368  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

346}
347
348size_t FBEBuffer::allocate(size_t size)
349{
350 size_t offset = _size;
351
352 // Calculate a new buffer size
353 size_t total = _size + size;
354
355 if (total <= _capacity)
356 {
357 _size = total;
358 return offset;
359 }
360
361 _capacity = std::max(total, 2 * _capacity);
362 uint8_t* data = (uint8_t*)std::malloc(_capacity);
363 std::memcpy(data, _data, _size);
364 std::free(_data);
365 _data = data;
366 _size = total;
367 return offset;
368}
369
370void FBEBuffer::remove(size_t offset, size_t size)
371{

Callers 14

set_beginMethod · 0.45
create_beginMethod · 0.45
serializeMethod · 0.45
setMethod · 0.45
receiveMethod · 0.45
serializeMethod · 0.45
serializeMethod · 0.45
set_beginMethod · 0.45
create_beginMethod · 0.45
set_beginMethod · 0.45
create_beginMethod · 0.45
set_beginMethod · 0.45

Calls

no outgoing calls

Tested by 3

set_beginMethod · 0.36
create_beginMethod · 0.36
serializeMethod · 0.36