MCPcopy Create free account
hub / github.com/ElementsProject/elements / GetVarint32PtrFallback

Function GetVarint32PtrFallback

src/leveldb/util/coding.cc:86–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84}
85
86const char* GetVarint32PtrFallback(const char* p, const char* limit,
87 uint32_t* value) {
88 uint32_t result = 0;
89 for (uint32_t shift = 0; shift <= 28 && p < limit; shift += 7) {
90 uint32_t byte = *(reinterpret_cast<const uint8_t*>(p));
91 p++;
92 if (byte & 128) {
93 // More bytes are present
94 result |= ((byte & 127) << shift);
95 } else {
96 result |= (byte << shift);
97 *value = result;
98 return reinterpret_cast<const char*>(p);
99 }
100 }
101 return nullptr;
102}
103
104bool GetVarint32(Slice* input, uint32_t* value) {
105 const char* p = input->data();

Callers 1

GetVarint32PtrFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected