diff options
author | Eugene Kliuchnikov <eustas.ru@gmail.com> | 2020-05-15 11:06:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-15 11:06:21 +0200 |
commit | 7f740f1308336e9ec0afdb9434896307859f5dc9 (patch) | |
tree | 72841d92798fabcfaec0b95091420ac37c82b86f /c | |
parent | f83aa5169e3c09afa8db84d1180fd1fe8813118a (diff) | |
download | brotli-7f740f1308336e9ec0afdb9434896307859f5dc9.tar.gz |
Update (#807)
- fix formatting
- fix type conversion
- fix no-op arithmetic with null-pointer
- improve performance of hash_longest_match64
- go: detect read after close
- java decoder: support compound dictionary
- remove executable flag on non-scripts
Diffstat (limited to 'c')
-rw-r--r--[-rwxr-xr-x] | c/common/context.h | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | c/common/dictionary.bin.br | bin | 51687 -> 51687 bytes | |||
-rw-r--r--[-rwxr-xr-x] | c/common/platform.h | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | c/common/transform.c | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | c/common/transform.h | 0 | ||||
-rw-r--r-- | c/dec/decode.c | 6 | ||||
-rw-r--r-- | c/dec/huffman.h | 2 | ||||
-rw-r--r-- | c/enc/compress_fragment_two_pass.c | 2 | ||||
-rw-r--r-- | c/enc/encode.c | 8 | ||||
-rw-r--r--[-rwxr-xr-x] | c/enc/encoder_dict.c | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | c/enc/encoder_dict.h | 0 | ||||
-rw-r--r-- | c/enc/fast_log.h | 7 | ||||
-rw-r--r--[-rwxr-xr-x] | c/enc/hash_composite_inc.h | 0 | ||||
-rw-r--r-- | c/enc/hash_longest_match64_inc.h | 2 | ||||
-rw-r--r--[-rwxr-xr-x] | c/enc/hash_rolling_inc.h | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | c/enc/params.h | 0 | ||||
-rw-r--r-- | c/enc/utf8_util.c | 2 |
17 files changed, 17 insertions, 12 deletions
diff --git a/c/common/context.h b/c/common/context.h index 24b3eb4..24b3eb4 100755..100644 --- a/c/common/context.h +++ b/c/common/context.h diff --git a/c/common/dictionary.bin.br b/c/common/dictionary.bin.br Binary files differindex 6a55d42..6a55d42 100755..100644 --- a/c/common/dictionary.bin.br +++ b/c/common/dictionary.bin.br diff --git a/c/common/platform.h b/c/common/platform.h index ca79359..ca79359 100755..100644 --- a/c/common/platform.h +++ b/c/common/platform.h diff --git a/c/common/transform.c b/c/common/transform.c index f8fa433..f8fa433 100755..100644 --- a/c/common/transform.c +++ b/c/common/transform.c diff --git a/c/common/transform.h b/c/common/transform.h index b6f86cc..b6f86cc 100755..100644 --- a/c/common/transform.h +++ b/c/common/transform.h diff --git a/c/dec/decode.c b/c/dec/decode.c index 114c505..9cdbb57 100644 --- a/c/dec/decode.c +++ b/c/dec/decode.c @@ -275,7 +275,8 @@ static BrotliDecoderErrorCode BROTLI_NOINLINE DecodeMetaBlockLength( s->loop_counter = i; return BROTLI_DECODER_NEEDS_MORE_INPUT; } - if (i + 1 == (int)s->size_nibbles && s->size_nibbles > 4 && bits == 0) { + if (i + 1 == (int)s->size_nibbles && s->size_nibbles > 4 && + bits == 0) { return BROTLI_FAILURE(BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE); } s->meta_block_remaining_len |= (int)(bits << (i * 4)); @@ -324,7 +325,8 @@ static BrotliDecoderErrorCode BROTLI_NOINLINE DecodeMetaBlockLength( s->loop_counter = i; return BROTLI_DECODER_NEEDS_MORE_INPUT; } - if (i + 1 == (int)s->size_nibbles && s->size_nibbles > 1 && bits == 0) { + if (i + 1 == (int)s->size_nibbles && s->size_nibbles > 1 && + bits == 0) { return BROTLI_FAILURE( BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE); } diff --git a/c/dec/huffman.h b/c/dec/huffman.h index 70e8469..2e01447 100644 --- a/c/dec/huffman.h +++ b/c/dec/huffman.h @@ -83,7 +83,7 @@ typedef BROTLI_ALIGNED(4) uint32_t HuffmanCode; static BROTLI_INLINE HuffmanCode ConstructHuffmanCode(const uint8_t bits, const uint16_t value) { - return ((value & 0xFFFF) << 16) | (bits & 0xFF); + return (HuffmanCode) ((value & 0xFFFF) << 16) | (bits & 0xFF); } #define BROTLI_HC_MARK_TABLE_FOR_FAST_LOAD(H) uint32_t __fastload_##H = (*H) diff --git a/c/enc/compress_fragment_two_pass.c b/c/enc/compress_fragment_two_pass.c index f8a5606..ca68b38 100644 --- a/c/enc/compress_fragment_two_pass.c +++ b/c/enc/compress_fragment_two_pass.c @@ -524,7 +524,7 @@ static void StoreCommands(MemoryManager* m, static BROTLI_BOOL ShouldCompress( const uint8_t* input, size_t input_size, size_t num_literals) { double corpus_size = (double)input_size; - if (num_literals < MIN_RATIO * corpus_size) { + if ((double)num_literals < MIN_RATIO * corpus_size) { return BROTLI_TRUE; } else { uint32_t literal_histo[256] = { 0 }; diff --git a/c/enc/encode.c b/c/enc/encode.c index 68548ef..8d90937 100644 --- a/c/enc/encode.c +++ b/c/enc/encode.c @@ -516,7 +516,7 @@ static BROTLI_BOOL ShouldCompress( /* TODO: find more precise minimal block overhead. */ if (bytes <= 2) return BROTLI_FALSE; if (num_commands < (bytes >> 8) + 2) { - if (num_literals > 0.99 * (double)bytes) { + if ((double)num_literals > 0.99 * (double)bytes) { uint32_t literal_histo[256] = { 0 }; static const uint32_t kSampleRate = 13; static const double kMinEntropy = 7.92; @@ -1686,8 +1686,10 @@ static BROTLI_BOOL BrotliEncoderCompressStreamFast( &storage_ix, storage); if (BROTLI_IS_OOM(m)) return BROTLI_FALSE; } - *next_in += block_size; - *available_in -= block_size; + if (block_size != 0) { + *next_in += block_size; + *available_in -= block_size; + } if (inplace) { size_t out_bytes = storage_ix >> 3; BROTLI_DCHECK(out_bytes <= *available_out); diff --git a/c/enc/encoder_dict.c b/c/enc/encoder_dict.c index c9e963b..c9e963b 100755..100644 --- a/c/enc/encoder_dict.c +++ b/c/enc/encoder_dict.c diff --git a/c/enc/encoder_dict.h b/c/enc/encoder_dict.h index a1c329f..a1c329f 100755..100644 --- a/c/enc/encoder_dict.h +++ b/c/enc/encoder_dict.h diff --git a/c/enc/fast_log.h b/c/enc/fast_log.h index eca58e8..45da68e 100644 --- a/c/enc/fast_log.h +++ b/c/enc/fast_log.h @@ -32,7 +32,7 @@ static BROTLI_INLINE uint32_t Log2FloorNonZero(size_t n) { computation. ", ".join(["%.16ff" % x for x in [0.0]+[log2(x) for x in range(1, 256)]]) */ -static const float kLog2Table[] = { +static const double kLog2Table[] = { 0.0000000000000000f, 0.0000000000000000f, 1.0000000000000000f, 1.5849625007211563f, 2.0000000000000000f, 2.3219280948873622f, 2.5849625007211561f, 2.8073549220576042f, 3.0000000000000000f, @@ -123,8 +123,9 @@ static const float kLog2Table[] = { /* Visual Studio 2012 and Android API levels < 18 do not have the log2() * function defined, so we use log() and a multiplication instead. */ -#ifndef BROTLI_HAVE_LOG2 -#if ((defined(_MSC_VER) && _MSC_VER <= 1700) || (defined(__ANDROID_API__) && __ANDROID_API__ < 18)) +#if !defined(BROTLI_HAVE_LOG2) +#if ((defined(_MSC_VER) && _MSC_VER <= 1700) || \ + (defined(__ANDROID_API__) && __ANDROID_API__ < 18)) #define BROTLI_HAVE_LOG2 0 #else #define BROTLI_HAVE_LOG2 1 diff --git a/c/enc/hash_composite_inc.h b/c/enc/hash_composite_inc.h index cba156c..cba156c 100755..100644 --- a/c/enc/hash_composite_inc.h +++ b/c/enc/hash_composite_inc.h diff --git a/c/enc/hash_longest_match64_inc.h b/c/enc/hash_longest_match64_inc.h index bdee7e4..956fb30 100644 --- a/c/enc/hash_longest_match64_inc.h +++ b/c/enc/hash_longest_match64_inc.h @@ -115,8 +115,8 @@ static BROTLI_INLINE void FN(Store)( self->hash_shift_); const size_t minor_ix = num[key] & self->block_mask_; const size_t offset = minor_ix + (key << self->block_bits_); - buckets[offset] = (uint32_t)ix; ++num[key]; + buckets[offset] = (uint32_t)ix; } static BROTLI_INLINE void FN(StoreRange)(HashLongestMatch* BROTLI_RESTRICT self, diff --git a/c/enc/hash_rolling_inc.h b/c/enc/hash_rolling_inc.h index 586ae73..586ae73 100755..100644 --- a/c/enc/hash_rolling_inc.h +++ b/c/enc/hash_rolling_inc.h diff --git a/c/enc/params.h b/c/enc/params.h index 54a7f00..54a7f00 100755..100644 --- a/c/enc/params.h +++ b/c/enc/params.h diff --git a/c/enc/utf8_util.c b/c/enc/utf8_util.c index 04a7805..e802b6a 100644 --- a/c/enc/utf8_util.c +++ b/c/enc/utf8_util.c @@ -77,7 +77,7 @@ BROTLI_BOOL BrotliIsMostlyUTF8( i += bytes_read; if (symbol < 0x110000) size_utf8 += bytes_read; } - return TO_BROTLI_BOOL(size_utf8 > min_fraction * (double)length); + return TO_BROTLI_BOOL((double)size_utf8 > min_fraction * (double)length); } #if defined(__cplusplus) || defined(c_plusplus) |