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

Function SignedLeb128Size

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

Returns the number of bytes needed to encode the value in unsigned LEB128.

Source from the content-addressed store, hash-verified

237
238// Returns the number of bytes needed to encode the value in unsigned LEB128.
239static inline uint32_t SignedLeb128Size(int32_t data) {
240 // Like UnsignedLeb128Size(), but we need one bit beyond the highest bit that differs from sign.
241 data = data ^ (data >> 31);
242 uint32_t x = 1 /* we need to encode the sign bit */ + 6 + 32 - CLZ(data | 1U);
243 return (x * 37) >> 8;
244}
245
246static inline uint8_t* EncodeUnsignedLeb128(uint8_t* dest, uint32_t value) {
247 uint8_t out = value & 0x7f;

Callers

nothing calls this directly

Calls 1

CLZFunction · 0.85

Tested by

no test coverage detected