MCPcopy Create free account
hub / github.com/Duet3D/RepRapFirmware / GetBytesLeft

Method GetBytesLeft

src/Platform/OutputMemory.cpp:396–408  ·  view source on GitHub ↗

Get the number of bytes left for continuous writing static*/

Source from the content-addressed store, hash-verified

394
395// Get the number of bytes left for continuous writing
396/*static*/ size_t OutputBuffer::GetBytesLeft(const OutputBuffer *writingBuffer) noexcept
397{
398 const size_t freeBuffers = OUTPUT_BUFFER_COUNT - usedOutputBuffers;
399 const size_t bytesLeft = OUTPUT_BUFFER_SIZE - writingBuffer->last->DataLength();
400
401 if (freeBuffers < RESERVED_OUTPUT_BUFFERS)
402 {
403 // Keep some space left to encapsulate the responses (e.g. via an HTTP header)
404 return bytesLeft;
405 }
406
407 return bytesLeft + (freeBuffers - RESERVED_OUTPUT_BUFFERS) * OUTPUT_BUFFER_SIZE;
408}
409
410// Truncate an output buffer to free up more memory. Returns the number of released bytes.
411// This never releases the first buffer in the chain, so call it with a large value of bytesNeeded to release all buffers except the first.

Callers

nothing calls this directly

Calls 1

DataLengthMethod · 0.45

Tested by

no test coverage detected