MCPcopy Create free account
hub / github.com/Monibuca/engine / Write

Method Write

util/buffer.go:54–65  ·  view source on GitHub ↗
(a []byte)

Source from the content-addressed store, hash-verified

52}
53
54func (b *LimitBuffer) Write(a []byte) (n int, err error) {
55 l := b.Len()
56 newL := l + len(a)
57 if c := b.Cap(); newL > c {
58 return 0, fmt.Errorf("LimitBuffer Write %d > %d", newL, c)
59 // panic(fmt.Sprintf("LimitBuffer Write %d > %d", newL, c))
60 } else {
61 b.Buffer = b.Buffer.SubBuf(0, newL)
62 copy(b.Buffer[l:], a)
63 }
64 return len(a), nil
65}
66
67// IBytes 用于区分传入的内存是否是复用内存,例如从网络中读取的数据,如果是复用内存,需要尽早复制
68type IBytes interface {

Callers 1

PacketizeRTPMethod · 0.95

Calls 3

LenMethod · 0.65
CapMethod · 0.65
SubBufMethod · 0.65

Tested by

no test coverage detected