mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-18 03:44:32 +01:00
Forgot to add these
This commit is contained in:
1 parent
c82e19a91e
commit
4b4e6e1acf
4 files changed
+212
No files matched your search
@@ -0,0 +1,35 @@
|
||||
#include "util/bits/varint.h"
|
||||
|
||||
namespace varint {
|
||||
|
||||
void Encode32(uint32 value, char **dest) {
|
||||
// Simple varint
|
||||
char *p = *dest;
|
||||
while (value > 127) {
|
||||
*p++ = (value & 127);
|
||||
value >>= 7;
|
||||
}
|
||||
*p++ = value | 0x80;
|
||||
*dest = p;
|
||||
}
|
||||
|
||||
uint32 Decode32(const char **ptr) {
|
||||
uint32 value = 0;
|
||||
const char *p = *ptr;
|
||||
while (true) {
|
||||
uint8 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