summaryrefslogtreecommitdiffstats
path: root/encoder_base.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2017-05-07 15:50:01 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2017-05-07 15:50:01 +0000
commitefe11df4b26426c3db4f96592e899b1f005a878e (patch)
tree4195bbbd046bc3e44a30202dc3284e45bad0f516 /encoder_base.c
parentReleasing debian version 1.8-5. (diff)
downloadclzip-efe11df4b26426c3db4f96592e899b1f005a878e.tar.xz
clzip-efe11df4b26426c3db4f96592e899b1f005a878e.zip
Merging upstream version 1.9.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'encoder_base.c')
-rw-r--r--encoder_base.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/encoder_base.c b/encoder_base.c
index 31cad3f..e384d22 100644
--- a/encoder_base.c
+++ b/encoder_base.c
@@ -1,5 +1,5 @@
/* Clzip - LZMA lossless data compressor
- Copyright (C) 2010-2016 Antonio Diaz Diaz.
+ Copyright (C) 2010-2017 Antonio Diaz Diaz.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -54,11 +54,11 @@ void Mb_normalize_pos( struct Matchfinder_base * const mb )
if( !mb->at_stream_end )
{
int i;
- const int offset = mb->pos - mb->dictionary_size - mb->before_size;
+ const int offset = mb->pos - mb->before_size - mb->dictionary_size;
const int size = mb->stream_pos - offset;
memmove( mb->buffer, mb->buffer + offset, size );
mb->partial_data_pos += offset;
- mb->pos -= offset;
+ mb->pos -= offset; /* pos = before_size + dictionary_size */
mb->stream_pos -= offset;
for( i = 0; i < mb->num_prev_positions; ++i )
mb->prev_positions[i] -= min( mb->prev_positions[i], offset );
@@ -69,10 +69,9 @@ void Mb_normalize_pos( struct Matchfinder_base * const mb )
}
-bool Mb_init( struct Matchfinder_base * const mb,
- const int before, const int dict_size,
- const int after_size, const int dict_factor,
- const int num_prev_positions23,
+bool Mb_init( struct Matchfinder_base * const mb, const int before,
+ const int dict_size, const int after_size,
+ const int dict_factor, const int num_prev_positions23,
const int pos_array_factor, const int ifd )
{
const int buffer_size_limit =
@@ -116,8 +115,9 @@ bool Mb_init( struct Matchfinder_base * const mb,
mb->num_prev_positions = size;
mb->pos_array_size = pos_array_factor * ( mb->dictionary_size + 1 );
size += mb->pos_array_size;
- if( size * sizeof (int32_t) <= size ) mb->prev_positions = 0;
- else mb->prev_positions = (int32_t *)malloc( size * sizeof (int32_t) );
+ if( size * sizeof mb->prev_positions[0] <= size ) mb->prev_positions = 0;
+ else mb->prev_positions =
+ (int32_t *)malloc( size * sizeof mb->prev_positions[0] );
if( !mb->prev_positions ) { free( mb->buffer ); return false; }
mb->pos_array = mb->prev_positions + mb->num_prev_positions;
for( i = 0; i < mb->num_prev_positions; ++i ) mb->prev_positions[i] = 0;
@@ -184,7 +184,7 @@ void LZeb_reset( struct LZ_encoder_base * const eb )
Bm_array_init( eb->bm_rep2, states );
Bm_array_init( eb->bm_len[0], states * pos_states );
Bm_array_init( eb->bm_dis_slot[0], len_states * (1 << dis_slot_bits) );
- Bm_array_init( eb->bm_dis, modeled_distances - end_dis_model );
+ Bm_array_init( eb->bm_dis, modeled_distances - end_dis_model + 1 );
Bm_array_init( eb->bm_align, dis_align_size );
Lm_init( &eb->match_len_model );
Lm_init( &eb->rep_len_model );