| 1341 | } |
| 1342 | |
| 1343 | static void addLengthDistance(uivector* values, size_t length, size_t distance) |
| 1344 | { |
| 1345 | /*values in encoded vector are those used by deflate: |
| 1346 | 0-255: literal bytes |
| 1347 | 256: end |
| 1348 | 257-285: length/distance pair (length code, followed by extra length bits, distance code, extra distance bits) |
| 1349 | 286-287: invalid*/ |
| 1350 | |
| 1351 | unsigned length_code = (unsigned)searchCodeIndex(LENGTHBASE, 29, length); |
| 1352 | unsigned extra_length = (unsigned)(length - LENGTHBASE[length_code]); |
| 1353 | unsigned dist_code = (unsigned)searchCodeIndex(DISTANCEBASE, 30, distance); |
| 1354 | unsigned extra_distance = (unsigned)(distance - DISTANCEBASE[dist_code]); |
| 1355 | |
| 1356 | uivector_push_back(values, length_code + FIRST_LENGTH_CODE_INDEX); |
| 1357 | uivector_push_back(values, extra_length); |
| 1358 | uivector_push_back(values, dist_code); |
| 1359 | uivector_push_back(values, extra_distance); |
| 1360 | } |
| 1361 | |
| 1362 | /*3 bytes of data get encoded into two bytes. The hash cannot use more than 3 |
| 1363 | bytes as input because 3 is the minimum match length for deflate*/ |
no test coverage detected