MCPcopy
hub / github.com/tinylib/msgp / ReadArrayHeaderBytes

Function ReadArrayHeaderBytes

msgp/read_bytes.go:229–264  ·  view source on GitHub ↗

ReadArrayHeaderBytes attempts to read the array header size off of 'b' and return the size and remaining bytes. Possible errors: - [ErrShortBytes] (too few bytes) - [TypeError] (not an array)

(b []byte)

Source from the content-addressed store, hash-verified

227// - [ErrShortBytes] (too few bytes)
228// - [TypeError] (not an array)
229func ReadArrayHeaderBytes(b []byte) (sz uint32, o []byte, err error) {
230 if len(b) < 1 {
231 return 0, nil, ErrShortBytes
232 }
233 lead := b[0]
234 b = b[1:]
235 if isfixarray(lead) {
236 sz = uint32(rfixarray(lead))
237 o = b
238 return
239 }
240
241 switch lead {
242 case marray16:
243 if len(b) < 2 {
244 err = ErrShortBytes
245 return
246 }
247 sz = uint32(big.Uint16(b))
248 o = b[2:]
249 return
250
251 case marray32:
252 if len(b) < 4 {
253 err = ErrShortBytes
254 return
255 }
256 sz = big.Uint32(b)
257 o = b[4:]
258 return
259
260 default:
261 err = badPrefix(ArrayType, lead)
262 return
263 }
264}
265
266// ReadBytesHeader reads the 'bin' header size
267// off of 'b' and returns the size and remaining bytes.

Callers 15

UnmarshalMsgMethod · 0.92
UnmarshalMsgMethod · 0.92
UnmarshalMsgMethod · 0.92
UnmarshalMsgMethod · 0.92
UnmarshalMsgMethod · 0.92
UnmarshalMsgMethod · 0.92
UnmarshalMsgMethod · 0.92
UnmarshalMsgMethod · 0.92
UnmarshalMsgMethod · 0.92
UnmarshalMsgMethod · 0.92
UnmarshalMsgMethod · 0.92
UnmarshalMsgMethod · 0.92

Calls 3

isfixarrayFunction · 0.85
rfixarrayFunction · 0.85
badPrefixFunction · 0.85

Tested by 3

TestReadArrayHeaderBytesFunction · 0.68
FuzzReadBytesFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…