| 60 | } |
| 61 | |
| 62 | const uint8_t *GetVarint32PtrFallback(const uint8_t *p, |
| 63 | const uint8_t *limit, |
| 64 | uint32_t* value) { |
| 65 | uint32_t result = 0; |
| 66 | for (uint32_t shift = 0; shift <= 28 && p < limit; shift += 7) { |
| 67 | uint32_t byte = *p; |
| 68 | p++; |
| 69 | if (byte & 128) { |
| 70 | // More bytes are present |
| 71 | result |= ((byte & 127) << shift); |
| 72 | } else { |
| 73 | result |= (byte << shift); |
| 74 | *value = result; |
| 75 | return p; |
| 76 | } |
| 77 | } |
| 78 | return nullptr; |
| 79 | } |
| 80 | |
| 81 | bool GetVarint32(Slice* input, uint32_t* value) { |
| 82 | const uint8_t *p = input->data(); |