From 25e3796f83edcaeec3c2f1a34dec30f0e7efe0ae Mon Sep 17 00:00:00 2001 From: Eugene Kliuchnikov Date: Mon, 29 Feb 2016 14:41:24 +0100 Subject: [PATCH] Fix most of ()->(void) and some missing includes. --- enc/backward_references.cc | 8 ++++---- enc/bit_cost.h | 2 -- enc/block_splitter.h | 2 +- enc/brotli_bit_stream.cc | 2 ++ enc/brotli_bit_stream.h | 1 + enc/command.h | 4 ++-- enc/compress_fragment.cc | 1 + enc/compress_fragment_two_pass.cc | 1 + enc/encode.cc | 7 ++++--- enc/encode.h | 8 ++++---- enc/hash.h | 24 ++++++++++++------------ enc/histogram.h | 4 ++-- enc/metablock.h | 2 +- enc/ringbuffer.h | 13 +++++++------ enc/streams.cc | 2 +- enc/streams.h | 10 +++++----- 16 files changed, 48 insertions(+), 43 deletions(-) diff --git a/enc/backward_references.cc b/enc/backward_references.cc index 02d956d..7611d22 100644 --- a/enc/backward_references.cc +++ b/enc/backward_references.cc @@ -26,7 +26,7 @@ static const double kInfinity = std::numeric_limits::infinity(); // Histogram based cost model for zopflification. class ZopfliCostModel { public: - ZopfliCostModel() : min_cost_cmd_(kInfinity) {} + ZopfliCostModel(void) : min_cost_cmd_(kInfinity) {} void SetFromCommands(size_t num_bytes, size_t position, @@ -117,7 +117,7 @@ class ZopfliCostModel { return literal_costs_[to] - literal_costs_[from]; } - double GetMinCostCmd() const { + double GetMinCostCmd(void) const { return min_cost_cmd_; } @@ -238,7 +238,7 @@ class StartPosQueue { explicit StartPosQueue(int bits) : mask_((1u << bits) - 1), q_(1 << bits), idx_(0) {} - void Clear() { + void Clear(void) { idx_ = 0; } @@ -263,7 +263,7 @@ class StartPosQueue { } } - size_t size() const { return std::min(idx_, mask_ + 1); } + size_t size(void) const { return std::min(idx_, mask_ + 1); } size_t GetStartPos(size_t k) const { return q_[(k + 1 - idx_) & mask_].first; diff --git a/enc/bit_cost.h b/enc/bit_cost.h index 32ad52e..f07221b 100644 --- a/enc/bit_cost.h +++ b/enc/bit_cost.h @@ -9,8 +9,6 @@ #ifndef BROTLI_ENC_BIT_COST_H_ #define BROTLI_ENC_BIT_COST_H_ - - #include "./entropy_encode.h" #include "./fast_log.h" #include "./types.h" diff --git a/enc/block_splitter.h b/enc/block_splitter.h index bbbfda9..4f69296 100644 --- a/enc/block_splitter.h +++ b/enc/block_splitter.h @@ -25,7 +25,7 @@ struct BlockSplitIterator { } } - void Next() { + void Next(void) { if (length_ == 0) { ++idx_; type_ = split_.types[idx_]; diff --git a/enc/brotli_bit_stream.cc b/enc/brotli_bit_stream.cc index 8fb12ce..212cc75 100644 --- a/enc/brotli_bit_stream.cc +++ b/enc/brotli_bit_stream.cc @@ -11,6 +11,7 @@ #include "./brotli_bit_stream.h" #include +#include /* free, malloc */ #include #include #include @@ -22,6 +23,7 @@ #include "./fast_log.h" #include "./prefix.h" #include "./write_bits.h" + namespace brotli { namespace { diff --git a/enc/brotli_bit_stream.h b/enc/brotli_bit_stream.h index b05f1e2..28e3926 100644 --- a/enc/brotli_bit_stream.h +++ b/enc/brotli_bit_stream.h @@ -18,6 +18,7 @@ #include +#include "./entropy_encode.h" #include "./metablock.h" #include "./types.h" diff --git a/enc/command.h b/enc/command.h index afb014b..031be59 100644 --- a/enc/command.h +++ b/enc/command.h @@ -104,7 +104,7 @@ struct Command { GetLengthCode(insertlen, 4, dist_prefix_ == 0, &cmd_prefix_, &cmd_extra_); } - uint32_t DistanceCode() const { + uint32_t DistanceCode(void) const { if (dist_prefix_ < 16) { return dist_prefix_; } @@ -114,7 +114,7 @@ struct Command { return (prefix << nbits) + extra + 12; } - uint32_t DistanceContext() const { + uint32_t DistanceContext(void) const { uint32_t r = cmd_prefix_ >> 6; uint32_t c = cmd_prefix_ & 7; if ((r == 0 || r == 2 || r == 4 || r == 7) && (c <= 2)) { diff --git a/enc/compress_fragment.cc b/enc/compress_fragment.cc index 047d7fe..8a0d059 100644 --- a/enc/compress_fragment.cc +++ b/enc/compress_fragment.cc @@ -22,6 +22,7 @@ #include "./fast_log.h" #include "./find_match_length.h" #include "./port.h" +#include "./types.h" #include "./write_bits.h" namespace brotli { diff --git a/enc/compress_fragment_two_pass.cc b/enc/compress_fragment_two_pass.cc index 8477603..e0d97cf 100644 --- a/enc/compress_fragment_two_pass.cc +++ b/enc/compress_fragment_two_pass.cc @@ -20,6 +20,7 @@ #include "./fast_log.h" #include "./find_match_length.h" #include "./port.h" +#include "./types.h" #include "./write_bits.h" namespace brotli { diff --git a/enc/encode.cc b/enc/encode.cc index f923f7d..7d90469 100644 --- a/enc/encode.cc +++ b/enc/encode.cc @@ -9,7 +9,8 @@ #include "./encode.h" #include -#include +#include /* free, malloc */ +#include /* memset */ #include #include "./backward_references.h" @@ -253,7 +254,7 @@ BrotliCompressor::BrotliCompressor(BrotliParams params) hashers_->Init(hash_type_); } -BrotliCompressor::~BrotliCompressor() { +BrotliCompressor::~BrotliCompressor(void) { delete[] storage_; free(commands_); delete ringbuffer_; @@ -812,7 +813,7 @@ class BrotliBlockReader { public: explicit BrotliBlockReader(size_t block_size) : block_size_(block_size), buf_(NULL) {} - ~BrotliBlockReader() { delete[] buf_; } + ~BrotliBlockReader(void) { delete[] buf_; } const uint8_t* Read(BrotliIn* in, size_t* bytes_read, bool* is_last) { *bytes_read = 0; diff --git a/enc/encode.h b/enc/encode.h index 167235c..cd6ab05 100644 --- a/enc/encode.h +++ b/enc/encode.h @@ -26,7 +26,7 @@ static const int kMinInputBlockBits = 16; static const int kMaxInputBlockBits = 24; struct BrotliParams { - BrotliParams() + BrotliParams(void) : mode(MODE_GENERIC), quality(11), lgwin(22), @@ -68,10 +68,10 @@ struct BrotliParams { class BrotliCompressor { public: explicit BrotliCompressor(BrotliParams params); - ~BrotliCompressor(); + ~BrotliCompressor(void); // The maximum input size that can be processed at once. - size_t input_block_size() const { return size_t(1) << params_.lgblock; } + size_t input_block_size(void) const { return size_t(1) << params_.lgblock; } // Encodes the data in input_buffer as a meta-block and writes it to // encoded_buffer (*encoded_size should be set to the size of @@ -129,7 +129,7 @@ class BrotliCompressor { void BrotliSetCustomDictionary(size_t size, const uint8_t* dict); // No-op, but we keep it here for API backward-compatibility. - void WriteStreamHeader() {} + void WriteStreamHeader(void) {} private: uint8_t* GetBrotliStorage(size_t size); diff --git a/enc/hash.h b/enc/hash.h index 1f5f168..db8acc2 100644 --- a/enc/hash.h +++ b/enc/hash.h @@ -92,7 +92,7 @@ inline double BackwardReferenceScoreUsingLastDistance(size_t copy_length, } struct BackwardMatch { - BackwardMatch() : distance(0), length_and_code(0) {} + BackwardMatch(void) : distance(0), length_and_code(0) {} BackwardMatch(size_t dist, size_t len) : distance(static_cast(dist)) @@ -103,10 +103,10 @@ struct BackwardMatch { , length_and_code(static_cast( (len << 5) | (len == len_code ? 0 : len_code))) {} - size_t length() const { + size_t length(void) const { return length_and_code >> 5; } - size_t length_code() const { + size_t length_code(void) const { size_t code = length_and_code & 31; return code ? code : length(); } @@ -123,15 +123,15 @@ struct BackwardMatch { template class HashLongestMatchQuickly { public: - HashLongestMatchQuickly() { + HashLongestMatchQuickly(void) { Reset(); } - void Reset() { + void Reset(void) { need_init_ = true; num_dict_lookups_ = 0; num_dict_matches_ = 0; } - void Init() { + void Init(void) { if (need_init_) { // It is not strictly necessary to fill this buffer here, but // not filling will make the results of the compression stochastic @@ -337,17 +337,17 @@ template class HashLongestMatch { public: - HashLongestMatch() { + HashLongestMatch(void) { Reset(); } - void Reset() { + void Reset(void) { need_init_ = true; num_dict_lookups_ = 0; num_dict_matches_ = 0; } - void Init() { + void Init(void) { if (need_init_) { memset(&num_[0], 0, sizeof(num_)); need_init_ = false; @@ -875,10 +875,10 @@ struct Hashers { typedef HashLongestMatch<15, 8, 16> H9; typedef HashToBinaryTree H10; - Hashers() : hash_h2(0), hash_h3(0), hash_h4(0), hash_h5(0), - hash_h6(0), hash_h7(0), hash_h8(0), hash_h9(0), hash_h10(0) {} + Hashers(void) : hash_h2(0), hash_h3(0), hash_h4(0), hash_h5(0), + hash_h6(0), hash_h7(0), hash_h8(0), hash_h9(0), hash_h10(0) {} - ~Hashers() { + ~Hashers(void) { delete hash_h2; delete hash_h3; delete hash_h4; diff --git a/enc/histogram.h b/enc/histogram.h index 298d316..a1153c8 100644 --- a/enc/histogram.h +++ b/enc/histogram.h @@ -25,10 +25,10 @@ struct BlockSplit; // A simple container for histograms of data in blocks. template struct Histogram { - Histogram() { + Histogram(void) { Clear(); } - void Clear() { + void Clear(void) { memset(data_, 0, sizeof(data_)); total_count_ = 0; bit_cost_ = std::numeric_limits::infinity(); diff --git a/enc/metablock.h b/enc/metablock.h index 00c739b..d192885 100644 --- a/enc/metablock.h +++ b/enc/metablock.h @@ -18,7 +18,7 @@ namespace brotli { struct BlockSplit { - BlockSplit() : num_types(0) {} + BlockSplit(void) : num_types(0) {} size_t num_types; std::vector types; diff --git a/enc/ringbuffer.h b/enc/ringbuffer.h index d523792..d31e5d9 100644 --- a/enc/ringbuffer.h +++ b/enc/ringbuffer.h @@ -9,6 +9,7 @@ #ifndef BROTLI_ENC_RINGBUFFER_H_ #define BROTLI_ENC_RINGBUFFER_H_ +#include /* free, realloc */ #include "./port.h" #include "./types.h" @@ -42,7 +43,7 @@ class RingBuffer { buffer_[-2] = buffer_[size_ - 2] = 0; buffer_[-1] = buffer_[size_ - 1] = 0; } - ~RingBuffer() { + ~RingBuffer(void) { delete [] data_; } @@ -72,18 +73,18 @@ class RingBuffer { } } - void Reset() { + void Reset(void) { pos_ = 0; } // Logical cursor position in the ring buffer. - uint32_t position() const { return pos_; } + uint32_t position(void) const { return pos_; } // Bit mask for getting the physical position for a logical position. - uint32_t mask() const { return mask_; } + uint32_t mask(void) const { return mask_; } - uint8_t *start() { return &buffer_[0]; } - const uint8_t *start() const { return &buffer_[0]; } + uint8_t *start(void) { return &buffer_[0]; } + const uint8_t *start(void) const { return &buffer_[0]; } private: void WriteTail(const uint8_t *bytes, size_t n) { diff --git a/enc/streams.cc b/enc/streams.cc index 2ea766f..17eda2d 100644 --- a/enc/streams.cc +++ b/enc/streams.cc @@ -84,7 +84,7 @@ BrotliFileIn::BrotliFileIn(FILE* f, size_t max_read_size) buf_(new char[max_read_size]), buf_size_(max_read_size) { } -BrotliFileIn::~BrotliFileIn() { +BrotliFileIn::~BrotliFileIn(void) { delete[] buf_; } diff --git a/enc/streams.h b/enc/streams.h index 68fc23c..7fb2809 100644 --- a/enc/streams.h +++ b/enc/streams.h @@ -19,7 +19,7 @@ namespace brotli { // Input interface for the compression routines. class BrotliIn { public: - virtual ~BrotliIn() {} + virtual ~BrotliIn(void) {} // Return a pointer to the next block of input of at most n bytes. // Return the actual length in *nread. @@ -32,7 +32,7 @@ class BrotliIn { // Output interface for the compression routines. class BrotliOut { public: - virtual ~BrotliOut() {} + virtual ~BrotliOut(void) {} // Write n bytes of data from buf. // Return true if all written, false otherwise. @@ -47,7 +47,7 @@ class BrotliMemIn : public BrotliIn { void Reset(const void* buf, size_t len); // returns the amount of data consumed - size_t position() const { return pos_; } + size_t position(void) const { return pos_; } const void* Read(size_t n, size_t* OUTPUT); @@ -65,7 +65,7 @@ class BrotliMemOut : public BrotliOut { void Reset(void* buf, size_t len); // returns the amount of data written - size_t position() const { return pos_; } + size_t position(void) const { return pos_; } bool Write(const void* buf, size_t n); @@ -96,7 +96,7 @@ class BrotliStringOut : public BrotliOut { class BrotliFileIn : public BrotliIn { public: BrotliFileIn(FILE* f, size_t max_read_size); - ~BrotliFileIn(); + ~BrotliFileIn(void); const void* Read(size_t n, size_t* bytes_read);