Lines Matching defs:dict

264 	struct dictionary dict;
286 static void dict_reset(struct dictionary *dict, struct xz_buf *b)
288 if (DEC_IS_SINGLE(dict->mode)) {
289 dict->buf = b->out + b->out_pos;
290 dict->end = b->out_size - b->out_pos;
293 dict->start = 0;
294 dict->pos = 0;
295 dict->limit = 0;
296 dict->full = 0;
300 static void dict_limit(struct dictionary *dict, size_t out_max)
302 if (dict->end - dict->pos <= out_max)
303 dict->limit = dict->end;
305 dict->limit = dict->pos + out_max;
309 static inline bool dict_has_space(const struct dictionary *dict)
311 return dict->pos < dict->limit;
320 static inline uint32_t dict_get(const struct dictionary *dict, uint32_t dist)
322 size_t offset = dict->pos - dist - 1;
324 if (dist >= dict->pos)
325 offset += dict->end;
327 return dict->full > 0 ? dict->buf[offset] : 0;
333 static inline void dict_put(struct dictionary *dict, uint8_t byte)
335 dict->buf[dict->pos++] = byte;
337 if (dict->full < dict->pos)
338 dict->full = dict->pos;
346 static bool dict_repeat(struct dictionary *dict, uint32_t *len, uint32_t dist)
351 if (dist >= dict->full || dist >= dict->size)
354 left = min_t(size_t, dict->limit - dict->pos, *len);
357 back = dict->pos - dist - 1;
358 if (dist >= dict->pos)
359 back += dict->end;
362 dict->buf[dict->pos++] = dict->buf[back++];
363 if (back == dict->end)
367 if (dict->full < dict->pos)
368 dict->full = dict->pos;
374 static void dict_uncompressed(struct dictionary *dict, struct xz_buf *b,
383 if (copy_size > dict->end - dict->pos)
384 copy_size = dict->end - dict->pos;
397 memmove(dict->buf + dict->pos, b->in + b->in_pos, copy_size);
398 dict->pos += copy_size;
400 if (dict->full < dict->pos)
401 dict->full = dict->pos;
403 if (DEC_IS_MULTI(dict->mode)) {
404 if (dict->pos == dict->end)
405 dict->pos = 0;
415 dict->start = dict->pos;
427 static uint32_t dict_flush(struct dictionary *dict, struct xz_buf *b)
429 size_t copy_size = dict->pos - dict->start;
431 if (DEC_IS_MULTI(dict->mode)) {
432 if (dict->pos == dict->end)
433 dict->pos = 0;
437 * decompression because in multi-call mode dict->buf
441 memcpy(b->out + b->out_pos, dict->buf + dict->start,
445 dict->start = dict->pos;
591 uint32_t prev_byte = dict_get(&s->dict, 0);
593 uint32_t high = (s->dict.pos & s->lzma.literal_pos_mask) << s->lzma.lc;
613 match_byte = dict_get(&s->dict, s->lzma.rep0) << 1;
631 dict_put(&s->dict, (uint8_t)symbol);
747 if (dict_has_space(&s->dict) && s->lzma.len > 0)
748 dict_repeat(&s->dict, &s->lzma.len, s->lzma.rep0);
754 while (dict_has_space(&s->dict) && !rc_limit_exceeded(&s->rc)) {
755 pos_state = s->dict.pos & s->lzma.pos_mask;
766 if (!dict_repeat(&s->dict, &s->lzma.len, s->lzma.rep0))
995 dict_reset(&s->dict, b);
1087 dict_limit(&s->dict, min_t(size_t,
1093 s->lzma2.uncompressed -= dict_flush(&s->dict, b);
1113 dict_uncompressed(&s->dict, b, &s->lzma2.compressed);
1132 s->dict.mode = mode;
1133 s->dict.size_max = dict_max;
1136 s->dict.buf = vmalloc(dict_max);
1137 if (s->dict.buf == NULL) {
1142 s->dict.buf = NULL;
1143 s->dict.allocated = 0;
1155 s->dict.size = 2 + (props & 1);
1156 s->dict.size <<= (props >> 1) + 11;
1158 if (DEC_IS_MULTI(s->dict.mode)) {
1159 if (s->dict.size > s->dict.size_max)
1162 s->dict.end = s->dict.size;
1164 if (DEC_IS_DYNALLOC(s->dict.mode)) {
1165 if (s->dict.allocated < s->dict.size) {
1166 s->dict.allocated = s->dict.size;
1167 vfree(s->dict.buf);
1168 s->dict.buf = vmalloc(s->dict.size);
1169 if (s->dict.buf == NULL) {
1170 s->dict.allocated = 0;
1189 if (DEC_IS_MULTI(s->dict.mode))
1190 vfree(s->dict.buf);