Read a SQLite varint (1-9 bytes). Returns bytes consumed.
| 1065 | |
| 1066 | // Read a SQLite varint (1-9 bytes). Returns bytes consumed. |
| 1067 | static int get_varint(const uint8_t *buf, uint64_t *out) { |
| 1068 | uint64_t v = 0; |
| 1069 | for (int i = 0; i < 8; i++) { |
| 1070 | v = (v << 7) | (uint64_t)(buf[i] & 0x7f); |
| 1071 | if ((buf[i] & 0x80) == 0) { |
| 1072 | *out = v; |
| 1073 | return i + 1; |
| 1074 | } |
| 1075 | } |
| 1076 | v = (v << 8) | (uint64_t)buf[8]; |
| 1077 | *out = v; |
| 1078 | return 9; |
| 1079 | } |
| 1080 | |
| 1081 | // If an index cell's payload exceeds X, rewrite it to spill the tail to |
| 1082 | // overflow pages: varint(payload_len) + payload[0..local) + u32(first_ovfl). |
no outgoing calls
no test coverage detected