| 2162 | } |
| 2163 | |
| 2164 | void write_varint(int f, int32 x) |
| 2165 | { |
| 2166 | char b[5]; |
| 2167 | uchar bit; |
| 2168 | int cnt; |
| 2169 | |
| 2170 | SIVAL(b, 1, x); |
| 2171 | |
| 2172 | for (cnt = 4; cnt > 1 && b[cnt] == 0; cnt--) {} |
| 2173 | bit = ((uchar)1<<(7-cnt+1)); |
| 2174 | |
| 2175 | if (CVAL(b, cnt) >= bit) { |
| 2176 | cnt++; |
| 2177 | *b = ~(bit-1); |
| 2178 | } else if (cnt > 1) |
| 2179 | *b = b[cnt] | ~(bit*2-1); |
| 2180 | else |
| 2181 | *b = b[1]; |
| 2182 | |
| 2183 | write_buf(f, b, cnt); |
| 2184 | } |
| 2185 | |
| 2186 | void write_varlong(int f, int64 x, uchar min_bytes) |
| 2187 | { |
no test coverage detected