MCPcopy Create free account
hub / github.com/git/git / decode_varint

Function decode_varint

varint.c:4–18  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2#include "varint.h"
3
4uint64_t decode_varint(const unsigned char **bufp)
5{
6 const unsigned char *buf = *bufp;
7 unsigned char c = *buf++;
8 uint64_t val = c & 127;
9 while (c & 128) {
10 val += 1;
11 if (!val || MSB(val, 7))
12 return 0; /* overflow */
13 c = *buf++;
14 val = (val << 7) + (c & 127);
15 }
16 *bufp = buf;
17 return val;
18}
19
20uint8_t encode_varint(uint64_t value, unsigned char *buf)
21{

Callers 3

read_one_dirFunction · 0.70
read_untracked_extensionFunction · 0.70
create_from_diskFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected