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

Function ReadExactBytes

msgp/read_bytes.go:870–917  ·  view source on GitHub ↗
(b []byte, into []byte)

Source from the content-addressed store, hash-verified

868}
869
870func ReadExactBytes(b []byte, into []byte) (o []byte, err error) {
871 if len(b) < 1 {
872 err = ErrShortBytes
873 return
874 }
875
876 lead := b[0]
877 var read uint32
878 b = b[1:]
879 switch lead {
880 case mbin8:
881 if len(b) < 1 {
882 err = ErrShortBytes
883 return
884 }
885
886 read = uint32(b[0])
887 b = b[1:]
888
889 case mbin16:
890 if len(b) < 2 {
891 err = ErrShortBytes
892 return
893 }
894 read = uint32(big.Uint16(b))
895 b = b[2:]
896
897 case mbin32:
898 if len(b) < 4 {
899 err = ErrShortBytes
900 return
901 }
902 read = big.Uint32(b)
903 b = b[4:]
904
905 default:
906 err = badPrefix(BinType, lead)
907 return
908 }
909
910 if read != uint32(len(into)) {
911 err = ArrayError{Wanted: uint32(len(into)), Got: read}
912 return
913 }
914
915 o = b[copy(into, b):]
916 return
917}
918
919// ReadStringZC reads a messagepack string field
920// without copying. The returned []byte points

Callers 1

FuzzReadBytesFunction · 0.85

Calls 1

badPrefixFunction · 0.85

Tested by 1

FuzzReadBytesFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…