MCPcopy
hub / github.com/golang/protobuf / DecodeRawBytes

Method DecodeRawBytes

proto/buffer.go:239–249  ·  view source on GitHub ↗

DecodeRawBytes consumes a length-prefixed raw bytes from the buffer. If alloc is specified, it returns a copy the raw bytes rather than a sub-slice of the buffer.

(alloc bool)

Source from the content-addressed store, hash-verified

237// If alloc is specified, it returns a copy the raw bytes
238// rather than a sub-slice of the buffer.
239func (b *Buffer) DecodeRawBytes(alloc bool) ([]byte, error) {
240 v, n := protowire.ConsumeBytes(b.buf[b.idx:])
241 if n < 0 {
242 return nil, protowire.ParseError(n)
243 }
244 b.idx += n
245 if alloc {
246 v = append([]byte(nil), v...)
247 }
248 return v, nil
249}
250
251// DecodeStringBytes consumes a length-prefixed raw bytes from the buffer.
252// It does not validate whether the raw bytes contain valid UTF-8.

Callers 2

DecodeMessageMethod · 0.95
TestBytesPrimitivesFunction · 0.80

Calls

no outgoing calls

Tested by 1

TestBytesPrimitivesFunction · 0.64