• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/xz/src/liblzma/common/

Lines Matching defs:index_hash

3 /// \file       index_hash.c
73 lzma_index_hash_init(lzma_index_hash *index_hash, lzma_allocator *allocator)
75 if (index_hash == NULL) {
76 index_hash = lzma_alloc(sizeof(lzma_index_hash), allocator);
77 if (index_hash == NULL)
81 index_hash->sequence = SEQ_BLOCK;
82 index_hash->blocks.blocks_size = 0;
83 index_hash->blocks.uncompressed_size = 0;
84 index_hash->blocks.count = 0;
85 index_hash->blocks.index_list_size = 0;
86 index_hash->records.blocks_size = 0;
87 index_hash->records.uncompressed_size = 0;
88 index_hash->records.count = 0;
89 index_hash->records.index_list_size = 0;
90 index_hash->unpadded_size = 0;
91 index_hash->uncompressed_size = 0;
92 index_hash->pos = 0;
93 index_hash->crc32 = 0;
96 (void)lzma_check_init(&index_hash->blocks.check, LZMA_CHECK_BEST);
97 (void)lzma_check_init(&index_hash->records.check, LZMA_CHECK_BEST);
99 return index_hash;
104 lzma_index_hash_end(lzma_index_hash *index_hash, lzma_allocator *allocator)
106 lzma_free(index_hash, allocator);
112 lzma_index_hash_size(const lzma_index_hash *index_hash)
117 return index_size(index_hash->blocks.count,
118 index_hash->blocks.index_list_size);
142 lzma_index_hash_append(lzma_index_hash *index_hash, lzma_vli unpadded_size,
146 if (index_hash->sequence != SEQ_BLOCK
153 return_if_error(hash_append(&index_hash->blocks,
157 if (index_hash->blocks.blocks_size > LZMA_VLI_MAX
158 || index_hash->blocks.uncompressed_size > LZMA_VLI_MAX
159 || index_size(index_hash->blocks.count,
160 index_hash->blocks.index_list_size)
162 || index_stream_size(index_hash->blocks.blocks_size,
163 index_hash->blocks.count,
164 index_hash->blocks.index_list_size)
173 lzma_index_hash_decode(lzma_index_hash *index_hash, const uint8_t *in,
189 switch (index_hash->sequence) {
195 index_hash->sequence = SEQ_COUNT;
199 ret = lzma_vli_decode(&index_hash->remaining,
200 &index_hash->pos, in, in_pos, in_size);
205 if (index_hash->remaining != index_hash->blocks.count)
209 index_hash->pos = 0;
212 index_hash->sequence = index_hash->remaining == 0
219 lzma_vli *size = index_hash->sequence == SEQ_UNPADDED
220 ? &index_hash->unpadded_size
221 : &index_hash->uncompressed_size;
223 ret = lzma_vli_decode(size, &index_hash->pos,
229 index_hash->pos = 0;
231 if (index_hash->sequence == SEQ_UNPADDED) {
232 if (index_hash->unpadded_size < UNPADDED_SIZE_MIN
233 || index_hash->unpadded_size
237 index_hash->sequence = SEQ_UNCOMPRESSED;
240 return_if_error(hash_append(&index_hash->records,
241 index_hash->unpadded_size,
242 index_hash->uncompressed_size));
247 // that values in index_hash->blocks are already
249 // exceed them in index_hash->records.
250 if (index_hash->blocks.blocks_size
251 < index_hash->records.blocks_size
252 || index_hash->blocks.uncompressed_size
253 < index_hash->records.uncompressed_size
254 || index_hash->blocks.index_list_size
255 < index_hash->records.index_list_size)
259 index_hash->sequence = --index_hash->remaining == 0
267 index_hash->pos = (LZMA_VLI_C(4) - index_size_unpadded(
268 index_hash->records.count,
269 index_hash->records.index_list_size)) & 3;
270 index_hash->sequence = SEQ_PADDING;
275 if (index_hash->pos > 0) {
276 --index_hash->pos;
284 if (index_hash->blocks.blocks_size
285 != index_hash->records.blocks_size
286 || index_hash->blocks.uncompressed_size
287 != index_hash->records.uncompressed_size
288 || index_hash->blocks.index_list_size
289 != index_hash->records.index_list_size)
293 lzma_check_finish(&index_hash->blocks.check, LZMA_CHECK_BEST);
294 lzma_check_finish(&index_hash->records.check, LZMA_CHECK_BEST);
295 if (memcmp(index_hash->blocks.check.buffer.u8,
296 index_hash->records.check.buffer.u8,
301 index_hash->crc32 = lzma_crc32(in + in_start,
302 *in_pos - in_start, index_hash->crc32);
304 index_hash->sequence = SEQ_CRC32;
313 if (((index_hash->crc32 >> (index_hash->pos * 8))
317 } while (++index_hash->pos < 4);
328 index_hash->crc32 = lzma_crc32(in + in_start,
329 *in_pos - in_start, index_hash->crc32);