mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-18 03:44:32 +01:00
Merge remote repo native into ext/native/.
This commit is contained in:
commit
f279c2a3c2
378 files changed
+190761
No files matched your search
@@ -0,0 +1,35 @@
|
||||
#include "util/bits/varint.h"
|
||||
|
||||
namespace varint {
|
||||
|
||||
void Encode32(uint32_t value, char **dest) {
|
||||
// Simple varint
|
||||
char *p = *dest;
|
||||
while (value > 127) {
|
||||
*p++ = (value & 127);
|
||||
value >>= 7;
|
||||
}
|
||||
*p++ = value | 0x80;
|
||||
*dest = p;
|
||||
}
|
||||
|
||||
uint32_t Decode32(const char **ptr) {
|
||||
uint32_t value = 0;
|
||||
const char *p = *ptr;
|
||||
while (true) {
|
||||
uint8_t b = *p++;
|
||||
if (b & 0x80) {
|
||||
*ptr = p;
|
||||
return value | (b & 0x7F);
|
||||
} else {
|
||||
value |= *p++;
|
||||
value <<= 7;
|
||||
}
|
||||
}
|
||||
*ptr = p;
|
||||
return value;
|
||||
}
|
||||
|
||||
} // namespace varint
|
||||
|
||||
|
||||
Reference in new issue
Block a user