diff options
Diffstat (limited to 'Utilities/cmliblzma/liblzma/delta')
-rw-r--r-- | Utilities/cmliblzma/liblzma/delta/delta_common.c | 4 | ||||
-rw-r--r-- | Utilities/cmliblzma/liblzma/delta/delta_decoder.c | 15 | ||||
-rw-r--r-- | Utilities/cmliblzma/liblzma/delta/delta_encoder.c | 9 |
3 files changed, 18 insertions, 10 deletions
diff --git a/Utilities/cmliblzma/liblzma/delta/delta_common.c b/Utilities/cmliblzma/liblzma/delta/delta_common.c index 930ad21..803e674 100644 --- a/Utilities/cmliblzma/liblzma/delta/delta_common.c +++ b/Utilities/cmliblzma/liblzma/delta/delta_common.c @@ -27,6 +27,8 @@ extern lzma_ret lzma_delta_coder_init(lzma_next_coder *next, lzma_allocator *allocator, const lzma_filter_info *filters) { + const lzma_options_delta *opt; + // Allocate memory for the decoder if needed. if (next->coder == NULL) { next->coder = lzma_alloc(sizeof(lzma_coder), allocator); @@ -43,7 +45,7 @@ lzma_delta_coder_init(lzma_next_coder *next, lzma_allocator *allocator, return LZMA_OPTIONS_ERROR; // Set the delta distance. - const lzma_options_delta *opt = filters[0].options; + opt = filters[0].options; next->coder->distance = opt->dist; // Initialize the rest of the variables. diff --git a/Utilities/cmliblzma/liblzma/delta/delta_decoder.c b/Utilities/cmliblzma/liblzma/delta/delta_decoder.c index 2cf60d5..582e58e 100644 --- a/Utilities/cmliblzma/liblzma/delta/delta_decoder.c +++ b/Utilities/cmliblzma/liblzma/delta/delta_decoder.c @@ -17,9 +17,10 @@ static void decode_buffer(lzma_coder *coder, uint8_t *buffer, size_t size) { + size_t i; const size_t distance = coder->distance; - for (size_t i = 0; i < size; ++i) { + for (i = 0; i < size; ++i) { buffer[i] += coder->history[(distance + coder->pos) & 0xFF]; coder->history[coder->pos-- & 0xFF] = buffer[i]; } @@ -32,11 +33,12 @@ delta_decode(lzma_coder *coder, lzma_allocator *allocator, size_t in_size, uint8_t *restrict out, size_t *restrict out_pos, size_t out_size, lzma_action action) { - assert(coder->next.code != NULL); - const size_t out_start = *out_pos; + lzma_ret ret; - const lzma_ret ret = coder->next.code(coder->next.coder, allocator, + assert(coder->next.code != NULL); + + ret = coder->next.code(coder->next.coder, allocator, in, in_pos, in_size, out, out_pos, out_size, action); @@ -59,11 +61,12 @@ extern lzma_ret lzma_delta_props_decode(void **options, lzma_allocator *allocator, const uint8_t *props, size_t props_size) { + lzma_options_delta *opt; + if (props_size != 1) return LZMA_OPTIONS_ERROR; - lzma_options_delta *opt - = lzma_alloc(sizeof(lzma_options_delta), allocator); + opt = lzma_alloc(sizeof(lzma_options_delta), allocator); if (opt == NULL) return LZMA_MEM_ERROR; diff --git a/Utilities/cmliblzma/liblzma/delta/delta_encoder.c b/Utilities/cmliblzma/liblzma/delta/delta_encoder.c index 15c7951..8b9e4a8 100644 --- a/Utilities/cmliblzma/liblzma/delta/delta_encoder.c +++ b/Utilities/cmliblzma/liblzma/delta/delta_encoder.c @@ -21,9 +21,10 @@ static void copy_and_encode(lzma_coder *coder, const uint8_t *restrict in, uint8_t *restrict out, size_t size) { + size_t i; const size_t distance = coder->distance; - for (size_t i = 0; i < size; ++i) { + for (i = 0; i < size; ++i) { const uint8_t tmp = coder->history[ (distance + coder->pos) & 0xFF]; coder->history[coder->pos-- & 0xFF] = in[i]; @@ -37,9 +38,10 @@ copy_and_encode(lzma_coder *coder, static void encode_in_place(lzma_coder *coder, uint8_t *buffer, size_t size) { + size_t i; const size_t distance = coder->distance; - for (size_t i = 0; i < size; ++i) { + for (i = 0; i < size; ++i) { const uint8_t tmp = coder->history[ (distance + coder->pos) & 0xFF]; coder->history[coder->pos-- & 0xFF] = buffer[i]; @@ -109,12 +111,13 @@ lzma_delta_encoder_init(lzma_next_coder *next, lzma_allocator *allocator, extern lzma_ret lzma_delta_props_encode(const void *options, uint8_t *out) { + const lzma_options_delta *opt = options; + // The caller must have already validated the options, so it's // LZMA_PROG_ERROR if they are invalid. if (lzma_delta_coder_memusage(options) == UINT64_MAX) return LZMA_PROG_ERROR; - const lzma_options_delta *opt = options; out[0] = opt->dist - LZMA_DELTA_DIST_MIN; return LZMA_OK; |