MCPcopy Create free account
hub / github.com/cloudwego/netpoll / Flush

Method Flush

nocopy_linkbuffer.go:469–488  ·  view source on GitHub ↗

Flush will submit all malloc data and must confirm that the allocated bytes have been correctly assigned.

()

Source from the content-addressed store, hash-verified

467
468// Flush will submit all malloc data and must confirm that the allocated bytes have been correctly assigned.
469func (b *UnsafeLinkBuffer) Flush() (err error) {
470 b.mallocSize = 0
471 // FIXME: The tail node must not be larger than 8KB to prevent Out Of Memory.
472 if cap(b.write.buf) > pagesize {
473 b.write.next = newLinkBufferNode(0)
474 b.write = b.write.next
475 }
476 var n int
477 for node := b.flush; node != b.write.next; node = node.next {
478 delta := node.malloc - len(node.buf)
479 if delta > 0 {
480 n += delta
481 node.buf = node.buf[:node.malloc]
482 }
483 }
484 b.flush = b.write
485 // re-cal length
486 b.recalLen(n)
487 return nil
488}
489
490// Append implements Writer.
491func (b *UnsafeLinkBuffer) Append(w Writer) (err error) {

Callers

nothing calls this directly

Calls 2

recalLenMethod · 0.95
newLinkBufferNodeFunction · 0.85

Tested by

no test coverage detected