mariadb/storage/tokudb/tokudb_vlq.h
Rich Prohaska 897964d945 refs #5947 rename to vlq
git-svn-id: file:///svn/mysql/tokudb-engine/tokudb-engine@52810 c7de825b-a66e-492c-adef-691d508d4ae1
2013-04-17 00:02:17 -04:00

34 lines
736 B
C++

#ifndef _TOKUDB_VLQ_H
#define _TOKUDB_VLQ_H
namespace tokudb {
static size_t vlq_encode_uint32(uint32_t n, void *p, size_t s) {
unsigned char *pp = (unsigned char *)p;
size_t i = 0;
while (n >= 128) {
pp[i++] = n%128;
n = n/128;
}
pp[i++] = 128+n;
return i;
}
static size_t vlq_decode_uint32(uint32_t *np, void *p, size_t s) {
unsigned char *pp = (unsigned char *)p;
uint32_t n = 0;
uint i = 0;
while (i < s) {
unsigned char m = pp[i];
n |= (m & 127) << 7*i;
i++;
if ((m & 128) != 0)
break;
}
*np = n;
return i;
}
}
#endif