| 1315 | } |
| 1316 | |
| 1317 | static void addLengthDistance(uivector* values, size_t length, size_t distance) |
| 1318 | { |
| 1319 | /*values in encoded vector are those used by deflate: |
| 1320 | 0-255: literal bytes |
| 1321 | 256: end |
| 1322 | 257-285: length/distance pair (length code, followed by extra length bits, distance code, extra distance bits) |
| 1323 | 286-287: invalid*/ |
| 1324 | |
| 1325 | unsigned length_code = (unsigned)searchCodeIndex(LENGTHBASE, 29, length); |
| 1326 | unsigned extra_length = (unsigned)(length - LENGTHBASE[length_code]); |
| 1327 | unsigned dist_code = (unsigned)searchCodeIndex(DISTANCEBASE, 30, distance); |
| 1328 | unsigned extra_distance = (unsigned)(distance - DISTANCEBASE[dist_code]); |
| 1329 | |
| 1330 | uivector_push_back(values, length_code + FIRST_LENGTH_CODE_INDEX); |
| 1331 | uivector_push_back(values, extra_length); |
| 1332 | uivector_push_back(values, dist_code); |
| 1333 | uivector_push_back(values, extra_distance); |
| 1334 | } |
| 1335 | |
| 1336 | /*3 bytes of data get encoded into two bytes. The hash cannot use more than 3 |
| 1337 | bytes as input because 3 is the minimum match length for deflate*/ |
no test coverage detected