MCPcopy Create free account
hub / github.com/segmentio/encoding / encodeBytes

Function encodeBytes

proto/bytes.go:26–42  ·  view source on GitHub ↗
(b []byte, p unsafe.Pointer, flags flags)

Source from the content-addressed store, hash-verified

24}
25
26func encodeBytes(b []byte, p unsafe.Pointer, flags flags) (int, error) {
27 if p != nil {
28 if v := *(*[]byte)(p); v != nil || flags.has(wantzero) {
29 n, err := encodeVarint(b, uint64(len(v)))
30 if err != nil {
31 return n, err
32 }
33 c := copy(b[n:], v)
34 n += c
35 if c < len(v) {
36 err = io.ErrShortBuffer
37 }
38 return n, err
39 }
40 }
41 return 0, nil
42}
43
44func decodeBytes(b []byte, p unsafe.Pointer, _ flags) (int, error) {
45 v, n, err := decodeVarlen(b)

Callers 1

byteArrayEncodeFuncOfFunction · 0.70

Calls 2

encodeVarintFunction · 0.85
hasMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…