MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / sliceResponseBuffers

Function sliceResponseBuffers

Libraries/HttpClient/HttpClient.cpp:462–477  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

460}
461
462static SC::Result sliceResponseBuffers(SC::Span<SC::HttpClientResponseBuffer> buffers, SC::Span<char> memory)
463{
464 SC_TRY_MSG(not buffers.empty(), "HttpClientOperation: response buffers missing");
465 SC_TRY_MSG(memory.sizeInBytes() >= buffers.sizeInElements(),
466 "HttpClientOperation: response buffer memory too small for slicing");
467
468 const size_t sliceSize = memory.sizeInBytes() / buffers.sizeInElements();
469 SC_TRY_MSG(sliceSize > 0, "HttpClientOperation: response buffer slices would be empty");
470
471 for (size_t idx = 0; idx < buffers.sizeInElements(); ++idx)
472 {
473 buffers[idx].data = {memory.data() + (idx * sliceSize),
474 idx + 1 == buffers.sizeInElements() ? memory.sizeInBytes() - idx * sliceSize : sliceSize};
475 }
476 return SC::Result(true);
477}
478} // namespace
479
480namespace

Callers 1

initMethod · 0.85

Calls 3

ResultClass · 0.50
sizeInBytesMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected