38 assert(matches[
i].len <= mf->nice_len);
39 assert(matches[
i].dist < mf->read_pos);
41 mf_ptr(mf) - matches[
i].dist - 2,
42 matches[
i].
len) == 0);
69 len_best = lzma_memcmplen(p1, p2, len_best,
limit);
86 #define EMPTY_HASH_VALUE 0
91 #define MUST_NORMALIZE_POS UINT32_MAX
121 if (mf->
hash[
i] <= subvalue)
124 mf->
hash[
i] -= subvalue;
135 if (mf->
son[
i] <= subvalue)
138 mf->
son[
i] -= subvalue;
191 #define header(is_bt, len_min, ret_op) \
192 uint32_t len_limit = mf_avail(mf); \
193 if (mf->nice_len <= len_limit) { \
194 len_limit = mf->nice_len; \
195 } else if (len_limit < (len_min) \
196 || (is_bt && mf->action == LZMA_SYNC_FLUSH)) { \
197 assert(mf->action != LZMA_RUN); \
201 const uint8_t *cur = mf_ptr(mf); \
202 const uint32_t pos = mf->read_pos + mf->offset
207 #define header_find(is_bt, len_min) \
208 header(is_bt, len_min, return 0); \
209 uint32_t matches_count = 0
214 #define header_skip(is_bt, len_min) \
215 header(is_bt, len_min, continue)
221 #define call_find(func, len_best) \
223 matches_count = func(len_limit, pos, cur, cur_match, mf->depth, \
224 mf->son, mf->cyclic_pos, mf->cyclic_size, \
225 matches + matches_count, len_best) \
228 return matches_count; \
236 #if defined(HAVE_MF_HC3) || defined(HAVE_MF_HC4)
262 son[cyclic_pos] = cur_match;
266 if (depth-- == 0 ||
delta >= cyclic_size)
270 cur_match = son[cyclic_pos -
delta
271 + (
delta > cyclic_pos ? cyclic_size : 0)];
273 if (pb[len_best] == cur[len_best] && pb[0] == cur[0]) {
274 uint32_t len = lzma_memcmplen(pb, cur, 1, len_limit);
276 if (len_best <
len) {
282 if (
len == len_limit)
290 #define hc_find(len_best) \
291 call_find(hc_find_func, len_best)
296 mf->son[mf->cyclic_pos] = cur_match; \
319 if (delta2 < mf->cyclic_size && *(cur - delta2) == *cur) {
320 len_best = lzma_memcmplen(cur - delta2, cur,
321 len_best, len_limit);
323 matches[0].
len = len_best;
324 matches[0].
dist = delta2 - 1;
327 if (len_best == len_limit) {
359 }
while (--amount != 0);
383 if (delta2 < mf->cyclic_size && *(cur - delta2) == *cur) {
386 matches[0].
dist = delta2 - 1;
390 if (delta2 != delta3 && delta3 < mf->cyclic_size
391 && *(cur - delta3) == *cur) {
393 matches[matches_count++].
dist = delta3 - 1;
397 if (matches_count != 0) {
398 len_best = lzma_memcmplen(cur - delta2, cur,
399 len_best, len_limit);
401 matches[matches_count - 1].
len = len_best;
403 if (len_best == len_limit) {
405 return matches_count;
439 }
while (--amount != 0);
448 #if defined(HAVE_MF_BT2) || defined(HAVE_MF_BT3) || defined(HAVE_MF_BT4)
462 uint32_t *ptr0 = son + (cyclic_pos << 1) + 1;
463 uint32_t *ptr1 = son + (cyclic_pos << 1);
470 if (depth-- == 0 ||
delta >= cyclic_size) {
477 + (
delta > cyclic_pos ? cyclic_size : 0))
483 if (pb[
len] == cur[
len]) {
484 len = lzma_memcmplen(pb, cur,
len + 1, len_limit);
486 if (len_best <
len) {
492 if (
len == len_limit) {
526 uint32_t *ptr0 = son + (cyclic_pos << 1) + 1;
527 uint32_t *ptr1 = son + (cyclic_pos << 1);
534 if (depth-- == 0 ||
delta >= cyclic_size) {
541 + (
delta > cyclic_pos ? cyclic_size : 0))
546 if (pb[
len] == cur[
len]) {
547 len = lzma_memcmplen(pb, cur,
len + 1, len_limit);
549 if (
len == len_limit) {
571 #define bt_find(len_best) \
572 call_find(bt_find_func, len_best)
576 bt_skip_func(len_limit, pos, cur, cur_match, mf->depth, \
577 mf->son, mf->cyclic_pos, \
613 }
while (--amount != 0);
634 if (delta2 < mf->cyclic_size && *(cur - delta2) == *cur) {
635 len_best = lzma_memcmplen(
636 cur, cur - delta2, len_best, len_limit);
638 matches[0].
len = len_best;
639 matches[0].
dist = delta2 - 1;
642 if (len_best == len_limit) {
668 }
while (--amount != 0);
692 if (delta2 < mf->cyclic_size && *(cur - delta2) == *cur) {
695 matches[0].
dist = delta2 - 1;
699 if (delta2 != delta3 && delta3 < mf->cyclic_size
700 && *(cur - delta3) == *cur) {
702 matches[matches_count++].
dist = delta3 - 1;
706 if (matches_count != 0) {
707 len_best = lzma_memcmplen(
708 cur, cur - delta2, len_best, len_limit);
710 matches[matches_count - 1].
len = len_best;
712 if (len_best == len_limit) {
714 return matches_count;
742 }
while (--amount != 0);
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void count
LZ in window and match finder API.
void lzma_mf_hc4_skip(lzma_mf *dict, uint32_t amount)
uint32_t lzma_mf_hc3_find(lzma_mf *dict, lzma_match *matches)
uint32_t lzma_mf_bt2_find(lzma_mf *dict, lzma_match *matches)
static uint32_t mf_avail(const lzma_mf *mf)
Get the number of bytes that haven't been ran through the match finder yet.
uint32_t lzma_mf_bt3_find(lzma_mf *dict, lzma_match *matches)
static const uint8_t * mf_ptr(const lzma_mf *mf)
Get pointer to the first byte not ran through the match finder.
uint32_t lzma_mf_bt4_find(lzma_mf *dict, lzma_match *matches)
void lzma_mf_bt2_skip(lzma_mf *dict, uint32_t amount)
void lzma_mf_bt3_skip(lzma_mf *dict, uint32_t amount)
void lzma_mf_hc3_skip(lzma_mf *dict, uint32_t amount)
void lzma_mf_bt4_skip(lzma_mf *dict, uint32_t amount)
uint32_t lzma_mf_hc4_find(lzma_mf *dict, lzma_match *matches)
Hash macros for match finders.
static void move_pending(lzma_mf *mf)
uint32_t lzma_mf_find(lzma_mf *mf, uint32_t *count_ptr, lzma_match *matches)
Find matches starting from the current byte.
static void normalize(lzma_mf *mf)
Normalizes hash values.
static void move_pos(lzma_mf *mf)
Mark the current byte as processed from point of view of the match finder.
#define MUST_NORMALIZE_POS
#define header_find(is_bt, len_min)
#define header_skip(is_bt, len_min)
Optimized comparison of two buffers.
assert(limit<=UINT32_MAX/2)
static uint32_t const uint8_t uint32_t uint32_t limit
uint32_t hash_count
Number of elements in hash[].
uint32_t(* find)(lzma_mf *mf, lzma_match *matches)
uint32_t nice_len
Maximum length of a match that the match finder will try to find.
uint32_t sons_count
Number of elements in son[].