MCPcopy Create free account
hub / github.com/CodingGay/BlackDex / DecodeUnsignedLeb128

Function DecodeUnsignedLeb128

Bcore/src/main/cpp/base/leb128.h:33–56  ·  view source on GitHub ↗

Reads an unsigned LEB128 value, updating the given pointer to point just past the end of the read value. This function tolerates non-zero high-order bits in the fifth encoded byte.

Source from the content-addressed store, hash-verified

31// just past the end of the read value. This function tolerates
32// non-zero high-order bits in the fifth encoded byte.
33static inline uint32_t DecodeUnsignedLeb128(const uint8_t** data) {
34 const uint8_t* ptr = *data;
35 int result = *(ptr++);
36 if (UNLIKELY(result > 0x7f)) {
37 int cur = *(ptr++);
38 result = (result & 0x7f) | ((cur & 0x7f) << 7);
39 if (cur > 0x7f) {
40 cur = *(ptr++);
41 result |= (cur & 0x7f) << 14;
42 if (cur > 0x7f) {
43 cur = *(ptr++);
44 result |= (cur & 0x7f) << 21;
45 if (cur > 0x7f) {
46 // Note: We don't check to see if cur is out of range here,
47 // meaning we tolerate garbage in the four high-order bits.
48 cur = *(ptr++);
49 result |= cur << 28;
50 }
51 }
52 }
53 }
54 *data = ptr;
55 return static_cast<uint32_t>(result);
56}
57
58static inline uint32_t DecodeUnsignedLeb128WithoutMovingCursor(const uint8_t* data) {
59 return DecodeUnsignedLeb128(&data);

Callers 14

GetStringLengthMethod · 0.85
DecodeDebugLocalInfoMethod · 0.85
NextMethod · 0.85
ReadClassDataHeaderMethod · 0.85
ReadClassDataFieldMethod · 0.85
ReadClassDataMethodMethod · 0.85
GetOffsetMethod · 0.85
CodeItemDataEndMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected