Read a SQLite varint (1-9 bytes). Returns bytes consumed.
| 1086 | |
| 1087 | // Read a SQLite varint (1-9 bytes). Returns bytes consumed. |
| 1088 | static int get_varint(const uint8_t *buf, uint64_t *out) { |
| 1089 | uint64_t v = 0; |
| 1090 | for (int i = 0; i < 8; i++) { |
| 1091 | v = (v << 7) | (uint64_t)(buf[i] & 0x7f); |
| 1092 | if ((buf[i] & 0x80) == 0) { |
| 1093 | *out = v; |
| 1094 | return i + 1; |
| 1095 | } |
| 1096 | } |
| 1097 | v = (v << 8) | (uint64_t)buf[8]; |
| 1098 | *out = v; |
| 1099 | return 9; |
| 1100 | } |
| 1101 | |
| 1102 | // If an index cell's payload exceeds X, rewrite it to spill the tail to |
| 1103 | // overflow pages: varint(payload_len) + payload[0..local) + u32(first_ovfl). |
no outgoing calls
no test coverage detected