MCPcopy Create free account
hub / github.com/cuberite/cuberite / ReadToByteBuffer

Method ReadToByteBuffer

src/ByteBuffer.cpp:805–823  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

803
804
805bool cByteBuffer::ReadToByteBuffer(cByteBuffer & a_Dst, size_t a_NumBytes)
806{
807 if (!a_Dst.CanWriteBytes(a_NumBytes) || !CanReadBytes(a_NumBytes))
808 {
809 // There's not enough source bytes or space in the dest BB
810 return false;
811 }
812 char buf[1024];
813 // > 0 without generating warnings about unsigned comparisons where size_t is unsigned
814 while (a_NumBytes != 0)
815 {
816 size_t num = (a_NumBytes > sizeof(buf)) ? sizeof(buf) : a_NumBytes;
817 VERIFY(ReadBuf(buf, num));
818 VERIFY(a_Dst.Write(buf, num));
819 ASSERT(a_NumBytes >= num);
820 a_NumBytes -= num;
821 }
822 return true;
823}
824
825
826

Callers 1

AddReceivedDataMethod · 0.80

Calls 2

CanWriteBytesMethod · 0.80
WriteMethod · 0.45

Tested by

no test coverage detected