1
0
Fork 0

Merging upstream version 1.5~rc1.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-17 20:29:24 +01:00
parent d95c5a0612
commit 12490d92a1
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
13 changed files with 119 additions and 100 deletions

View file

@ -73,7 +73,8 @@ bool Mf_init( struct Matchfinder * const mf,
const int dict_size, const int match_len_limit, const int ifd )
{
const int buffer_size_limit = ( 2 * dict_size ) + before_size + after_size;
int i, size;
unsigned size;
int i;
mf->partial_data_pos = 0;
mf->match_len_limit = match_len_limit;
@ -105,7 +106,7 @@ bool Mf_init( struct Matchfinder * const mf,
mf->pos_limit = mf->buffer_size;
if( !mf->at_stream_end ) mf->pos_limit -= after_size;
size = 1 << max( 16, real_bits( mf->dictionary_size - 1 ) - 2 );
if( mf->dictionary_size > 1 << 26 )
if( mf->dictionary_size > 1 << 26 ) /* 64 MiB */
size >>= 1;
mf->key4_mask = size - 1;
size += num_prev_positions2;
@ -113,7 +114,8 @@ bool Mf_init( struct Matchfinder * const mf,
mf->num_prev_positions = size;
size += ( 2 * ( mf->dictionary_size + 1 ) );
mf->prev_positions = (int32_t *)malloc( size * sizeof (int32_t) );
if( size * sizeof (int32_t) <= size ) mf->prev_positions = 0;
else mf->prev_positions = (int32_t *)malloc( size * sizeof (int32_t) );
if( !mf->prev_positions ) { free( mf->buffer ); return false; }
mf->prev_pos_tree = mf->prev_positions + mf->num_prev_positions;
for( i = 0; i < mf->num_prev_positions; ++i ) mf->prev_positions[i] = -1;