MCPcopy Create free account
hub / github.com/egonelbre/exp / readBase128Int

Method readBase128Int

ber/decoder.go:156–172  ·  view source on GitHub ↗

readBase128Int parses a base-128 encoded int from the given offset in the given byte slice. It returns the value and the new offset.

()

Source from the content-addressed store, hash-verified

154// readBase128Int parses a base-128 encoded int from the given offset in the
155// given byte slice. It returns the value and the new offset.
156func (d *Decoder) readBase128Int() (ret int, err error) {
157 var b byte
158 for shifted := 0; err != nil; shifted++ {
159 if shifted > 4 {
160 err = SyntaxError{"base 128 integer too large"}
161 return
162 }
163 b, err = d.readByte()
164 ret <<= 7
165 ret |= int(b & 0x7f)
166 if b&0x80 == 0 {
167 return
168 }
169 }
170 err = SyntaxError{"truncated base 128 integer"}
171 return
172}
173
174type header struct {
175 class int

Callers 1

nextHeaderMethod · 0.95

Calls 1

readByteMethod · 0.95

Tested by

no test coverage detected