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

Function UpdateUnsignedLeb128

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

Overwrite encoded Leb128 with a new value. The new value must be less than or equal to the old value to ensure that it fits the allocated space.

Source from the content-addressed store, hash-verified

271// Overwrite encoded Leb128 with a new value. The new value must be less than
272// or equal to the old value to ensure that it fits the allocated space.
273static inline void UpdateUnsignedLeb128(uint8_t* dest, uint32_t value) {
274 const uint8_t* old_end = dest;
275 uint32_t old_value = DecodeUnsignedLeb128(&old_end);
276 DCHECK_LE(UnsignedLeb128Size(value), UnsignedLeb128Size(old_value));
277 for (uint8_t* end = EncodeUnsignedLeb128(dest, value); end < old_end; end++) {
278 // Use longer encoding than necessary to fill the allocated space.
279 end[-1] |= 0x80;
280 end[0] = 0;
281 }
282}
283
284static inline uint8_t* EncodeSignedLeb128(uint8_t* dest, int32_t value) {
285 uint32_t extra_bits = static_cast<uint32_t>(value ^ (value >> 31)) >> 6;

Callers 1

UnHideAccessFlagsMethod · 0.85

Calls 3

DecodeUnsignedLeb128Function · 0.85
UnsignedLeb128SizeFunction · 0.85
EncodeUnsignedLeb128Function · 0.85

Tested by

no test coverage detected