Flush will submit all malloc data and must confirm that the allocated bytes have been correctly assigned.
()
| 467 | |
| 468 | // Flush will submit all malloc data and must confirm that the allocated bytes have been correctly assigned. |
| 469 | func (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. |
| 491 | func (b *UnsafeLinkBuffer) Append(w Writer) (err error) { |
nothing calls this directly
no test coverage detected