MCPcopy Create free account
hub / github.com/IceFireDB/IceFireDB / AppendLengthEncodedInteger

Function AppendLengthEncodedInteger

IceFireDB-SQLite/pkg/mysql/mysql/util.go:93–106  ·  view source on GitHub ↗

AppendLengthEncodedInteger: encodes a uint64 value and appends it to the given bytes slice

(b []byte, n uint64)

Source from the content-addressed store, hash-verified

91
92// AppendLengthEncodedInteger: encodes a uint64 value and appends it to the given bytes slice
93func AppendLengthEncodedInteger(b []byte, n uint64) []byte {
94 switch {
95 case n <= 250:
96 return append(b, byte(n))
97
98 case n <= 0xffff:
99 return append(b, 0xfc, byte(n), byte(n>>8))
100
101 case n <= 0xffffff:
102 return append(b, 0xfd, byte(n), byte(n>>8), byte(n>>16))
103 }
104 return append(b, 0xfe, byte(n), byte(n>>8), byte(n>>16), byte(n>>24),
105 byte(n>>32), byte(n>>40), byte(n>>48), byte(n>>56))
106}
107
108func RandomBuf(size int) ([]byte, error) {
109 buf := make([]byte, size)

Callers 1

writeAuthHandshakeMethod · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected