MCPcopy Create free account
hub / github.com/google/pprof / decodeField

Function decodeField

profile/proto.go:214–257  ·  view source on GitHub ↗
(b *buffer, data []byte)

Source from the content-addressed store, hash-verified

212}
213
214func decodeField(b *buffer, data []byte) ([]byte, error) {
215 x, data, err := decodeVarint(data)
216 if err != nil {
217 return nil, err
218 }
219 b.field = int(x >> 3)
220 b.typ = int(x & 7)
221 b.data = nil
222 b.u64 = 0
223 switch b.typ {
224 case 0:
225 b.u64, data, err = decodeVarint(data)
226 if err != nil {
227 return nil, err
228 }
229 case 1:
230 if len(data) < 8 {
231 return nil, errors.New("not enough data")
232 }
233 b.u64 = le64(data[:8])
234 data = data[8:]
235 case 2:
236 var n uint64
237 n, data, err = decodeVarint(data)
238 if err != nil {
239 return nil, err
240 }
241 if n > uint64(len(data)) {
242 return nil, errors.New("too much data")
243 }
244 b.data = data[:n]
245 data = data[n:]
246 case 5:
247 if len(data) < 4 {
248 return nil, errors.New("not enough data")
249 }
250 b.u64 = uint64(le32(data[:4]))
251 data = data[4:]
252 default:
253 return nil, fmt.Errorf("unknown wire type: %d", b.typ)
254 }
255
256 return data, nil
257}
258
259func checkType(b *buffer, typ int) error {
260 if b.typ != typ {

Callers 1

decodeMessageFunction · 0.85

Calls 3

decodeVarintFunction · 0.85
le64Function · 0.85
le32Function · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…