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