| 89 | } |
| 90 | |
| 91 | const char *GetVarint32PtrFallback(const char *p, const char *limit, uint32_t *value) { |
| 92 | uint32_t result = 0; |
| 93 | for (uint32_t shift = 0; shift <= 28 && p < limit; shift += 7) { |
| 94 | uint32_t byte = static_cast<unsigned char>(*p); |
| 95 | p++; |
| 96 | if (byte & 0x80) { |
| 97 | // More bytes are present |
| 98 | result |= ((byte & 0x7F) << shift); |
| 99 | } else { |
| 100 | result |= (byte << shift); |
| 101 | *value = result; |
| 102 | return p; |
| 103 | } |
| 104 | } |
| 105 | return nullptr; |
| 106 | } |
| 107 | |
| 108 | const char *GetVarint32Ptr(const char *p, const char *limit, uint32_t *value) { |
| 109 | if (p < limit) { |