MCPcopy Create free account
hub / github.com/cockroachdb/redact / Write

Method Write

internal/buffer/buffer.go:131–138  ·  view source on GitHub ↗

Write appends the contents of p to the buffer, growing the buffer as needed. The return value n is the length of p; err is always nil. If the buffer becomes too large, Write will panic with ErrTooLarge.

(p []byte)

Source from the content-addressed store, hash-verified

129// needed. The return value n is the length of p; err is always nil. If the
130// buffer becomes too large, Write will panic with ErrTooLarge.
131func (b *Buffer) Write(p []byte) (n int, err error) {
132 b.startWrite()
133 m, ok := b.tryGrowByReslice(len(p))
134 if !ok {
135 m = b.grow(len(p))
136 }
137 return copy(b.buf[m:], p), nil
138}
139
140// WriteString appends the contents of s to the buffer, growing the buffer as
141// needed. The return value n is the length of s; err is always nil. If the

Callers 4

TestBufferUnsafeWritesFunction · 0.95
TestBufferRawSafeWritesFunction · 0.95
Example_mixed_writesFunction · 0.95

Calls 3

startWriteMethod · 0.95
tryGrowByResliceMethod · 0.95
growMethod · 0.95

Tested by 4

TestBufferUnsafeWritesFunction · 0.76
TestBufferRawSafeWritesFunction · 0.76
Example_mixed_writesFunction · 0.76