Fix most of ()->(void) and some missing includes.

This commit is contained in:
Eugene Kliuchnikov 2016-02-29 14:41:24 +01:00
parent 7e5bbd5f9b
commit 25e3796f83
16 changed files with 48 additions and 43 deletions

View File

@ -26,7 +26,7 @@ static const double kInfinity = std::numeric_limits<double>::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;

View File

@ -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"

View File

@ -25,7 +25,7 @@ struct BlockSplitIterator {
}
}
void Next() {
void Next(void) {
if (length_ == 0) {
++idx_;
type_ = split_.types[idx_];

View File

@ -11,6 +11,7 @@
#include "./brotli_bit_stream.h"
#include <algorithm>
#include <cstdlib> /* free, malloc */
#include <cstring>
#include <limits>
#include <vector>
@ -22,6 +23,7 @@
#include "./fast_log.h"
#include "./prefix.h"
#include "./write_bits.h"
namespace brotli {
namespace {

View File

@ -18,6 +18,7 @@
#include <vector>
#include "./entropy_encode.h"
#include "./metablock.h"
#include "./types.h"

View File

@ -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)) {

View File

@ -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 {

View File

@ -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 {

View File

@ -9,7 +9,8 @@
#include "./encode.h"
#include <algorithm>
#include <cstring>
#include <cstdlib> /* free, malloc */
#include <cstring> /* memset */
#include <limits>
#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;

View File

@ -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);

View File

@ -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<uint32_t>(dist))
@ -103,10 +103,10 @@ struct BackwardMatch {
, length_and_code(static_cast<uint32_t>(
(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 <int kBucketBits, int kBucketSweep, bool kUseDictionary>
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 <int kBucketBits,
int kNumLastDistancesToCheck>
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;

View File

@ -25,10 +25,10 @@ struct BlockSplit;
// A simple container for histograms of data in blocks.
template<int kDataSize>
struct Histogram {
Histogram() {
Histogram(void) {
Clear();
}
void Clear() {
void Clear(void) {
memset(data_, 0, sizeof(data_));
total_count_ = 0;
bit_cost_ = std::numeric_limits<double>::infinity();

View File

@ -18,7 +18,7 @@
namespace brotli {
struct BlockSplit {
BlockSplit() : num_types(0) {}
BlockSplit(void) : num_types(0) {}
size_t num_types;
std::vector<uint8_t> types;

View File

@ -9,6 +9,7 @@
#ifndef BROTLI_ENC_RINGBUFFER_H_
#define BROTLI_ENC_RINGBUFFER_H_
#include <cstdlib> /* 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) {

View File

@ -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_;
}

View File

@ -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);