| index_decoder.c | index_decoder.c | |||
|---|---|---|---|---|
| skipping to change at line 55 | skipping to change at line 55 | |||
| lzma_vli uncompressed_size; | lzma_vli uncompressed_size; | |||
| /// Position in integers | /// Position in integers | |||
| size_t pos; | size_t pos; | |||
| /// CRC32 of the List of Records field | /// CRC32 of the List of Records field | |||
| uint32_t crc32; | uint32_t crc32; | |||
| }; | }; | |||
| static lzma_ret | static lzma_ret | |||
| index_decode(lzma_coder *coder, lzma_allocator *allocator, | index_decode(lzma_coder *coder, const lzma_allocator *allocator, | |||
| const uint8_t *restrict in, size_t *restrict in_pos, | const uint8_t *restrict in, size_t *restrict in_pos, | |||
| size_t in_size, | size_t in_size, | |||
| uint8_t *restrict out lzma_attribute((__unused__)), | uint8_t *restrict out lzma_attribute((__unused__)), | |||
| size_t *restrict out_pos lzma_attribute((__unused__)), | size_t *restrict out_pos lzma_attribute((__unused__)), | |||
| size_t out_size lzma_attribute((__unused__)), | size_t out_size lzma_attribute((__unused__)), | |||
| lzma_action action lzma_attribute((__unused__))) | lzma_action action lzma_attribute((__unused__))) | |||
| { | { | |||
| // Similar optimization as in index_encoder.c | // Similar optimization as in index_encoder.c | |||
| const size_t in_start = *in_pos; | const size_t in_start = *in_pos; | |||
| lzma_ret ret = LZMA_OK; | lzma_ret ret = LZMA_OK; | |||
| skipping to change at line 207 | skipping to change at line 207 | |||
| out: | out: | |||
| // Update the CRC32, | // Update the CRC32, | |||
| coder->crc32 = lzma_crc32(in + in_start, | coder->crc32 = lzma_crc32(in + in_start, | |||
| *in_pos - in_start, coder->crc32); | *in_pos - in_start, coder->crc32); | |||
| return ret; | return ret; | |||
| } | } | |||
| static void | static void | |||
| index_decoder_end(lzma_coder *coder, lzma_allocator *allocator) | index_decoder_end(lzma_coder *coder, const lzma_allocator *allocator) | |||
| { | { | |||
| lzma_index_end(coder->index, allocator); | lzma_index_end(coder->index, allocator); | |||
| lzma_free(coder, allocator); | lzma_free(coder, allocator); | |||
| return; | return; | |||
| } | } | |||
| static lzma_ret | static lzma_ret | |||
| index_decoder_memconfig(lzma_coder *coder, uint64_t *memusage, | index_decoder_memconfig(lzma_coder *coder, uint64_t *memusage, | |||
| uint64_t *old_memlimit, uint64_t new_memlimit) | uint64_t *old_memlimit, uint64_t new_memlimit) | |||
| { | { | |||
| skipping to change at line 232 | skipping to change at line 232 | |||
| if (new_memlimit < *memusage) | if (new_memlimit < *memusage) | |||
| return LZMA_MEMLIMIT_ERROR; | return LZMA_MEMLIMIT_ERROR; | |||
| coder->memlimit = new_memlimit; | coder->memlimit = new_memlimit; | |||
| } | } | |||
| return LZMA_OK; | return LZMA_OK; | |||
| } | } | |||
| static lzma_ret | static lzma_ret | |||
| index_decoder_reset(lzma_coder *coder, lzma_allocator *allocator, | index_decoder_reset(lzma_coder *coder, const lzma_allocator *allocator, | |||
| lzma_index **i, uint64_t memlimit) | lzma_index **i, uint64_t memlimit) | |||
| { | { | |||
| // Remember the pointer given by the application. We will set it | // Remember the pointer given by the application. We will set it | |||
| // to point to the decoded Index only if decoding is successful. | // to point to the decoded Index only if decoding is successful. | |||
| // Before that, keep it NULL so that applications can always safely | // Before that, keep it NULL so that applications can always safely | |||
| // pass it to lzma_index_end() no matter did decoding succeed or not . | // pass it to lzma_index_end() no matter did decoding succeed or not . | |||
| coder->index_ptr = i; | coder->index_ptr = i; | |||
| *i = NULL; | *i = NULL; | |||
| // We always allocate a new lzma_index. | // We always allocate a new lzma_index. | |||
| skipping to change at line 258 | skipping to change at line 258 | |||
| coder->sequence = SEQ_INDICATOR; | coder->sequence = SEQ_INDICATOR; | |||
| coder->memlimit = memlimit; | coder->memlimit = memlimit; | |||
| coder->count = 0; // Needs to be initialized due to _memconfig(). | coder->count = 0; // Needs to be initialized due to _memconfig(). | |||
| coder->pos = 0; | coder->pos = 0; | |||
| coder->crc32 = 0; | coder->crc32 = 0; | |||
| return LZMA_OK; | return LZMA_OK; | |||
| } | } | |||
| static lzma_ret | static lzma_ret | |||
| index_decoder_init(lzma_next_coder *next, lzma_allocator *allocator, | index_decoder_init(lzma_next_coder *next, const lzma_allocator *allocator, | |||
| lzma_index **i, uint64_t memlimit) | lzma_index **i, uint64_t memlimit) | |||
| { | { | |||
| lzma_next_coder_init(&index_decoder_init, next, allocator); | lzma_next_coder_init(&index_decoder_init, next, allocator); | |||
| if (i == NULL || memlimit == 0) | if (i == NULL || memlimit == 0) | |||
| return LZMA_PROG_ERROR; | return LZMA_PROG_ERROR; | |||
| if (next->coder == NULL) { | if (next->coder == NULL) { | |||
| next->coder = lzma_alloc(sizeof(lzma_coder), allocator); | next->coder = lzma_alloc(sizeof(lzma_coder), allocator); | |||
| if (next->coder == NULL) | if (next->coder == NULL) | |||
| skipping to change at line 294 | skipping to change at line 294 | |||
| { | { | |||
| lzma_next_strm_init(index_decoder_init, strm, i, memlimit); | lzma_next_strm_init(index_decoder_init, strm, i, memlimit); | |||
| strm->internal->supported_actions[LZMA_RUN] = true; | strm->internal->supported_actions[LZMA_RUN] = true; | |||
| strm->internal->supported_actions[LZMA_FINISH] = true; | strm->internal->supported_actions[LZMA_FINISH] = true; | |||
| return LZMA_OK; | return LZMA_OK; | |||
| } | } | |||
| extern LZMA_API(lzma_ret) | extern LZMA_API(lzma_ret) | |||
| lzma_index_buffer_decode( | lzma_index_buffer_decode(lzma_index **i, uint64_t *memlimit, | |||
| lzma_index **i, uint64_t *memlimit, lzma_allocator *allocato | const lzma_allocator *allocator, | |||
| r, | ||||
| const uint8_t *in, size_t *in_pos, size_t in_size) | const uint8_t *in, size_t *in_pos, size_t in_size) | |||
| { | { | |||
| // Sanity checks | // Sanity checks | |||
| if (i == NULL || memlimit == NULL | if (i == NULL || memlimit == NULL | |||
| || in == NULL || in_pos == NULL || *in_pos > in_size ) | || in == NULL || in_pos == NULL || *in_pos > in_size ) | |||
| return LZMA_PROG_ERROR; | return LZMA_PROG_ERROR; | |||
| // Initialize the decoder. | // Initialize the decoder. | |||
| lzma_coder coder; | lzma_coder coder; | |||
| return_if_error(index_decoder_reset(&coder, allocator, i, *memlimit) ); | return_if_error(index_decoder_reset(&coder, allocator, i, *memlimit) ); | |||
| End of changes. 5 change blocks. | ||||
| 7 lines changed or deleted | 6 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ | ||||