diff options
author | Matt Callanan <mpcallanan@google.com> | 2022-10-08 03:11:32 +0200 |
---|---|---|
committer | qrczak <qrczak@google.com> | 2022-10-08 08:41:35 +0200 |
commit | 974fcc49e8b6892ab9c42e2bf69ca1eb61f4e4c7 (patch) | |
tree | 9fe33cd7c2a7f5bc5557a762f0c5bfc099930ffe | |
parent | d644ca87706548b9a8bf1e13d7669c13c2607b7e (diff) | |
download | snappy-git-974fcc49e8b6892ab9c42e2bf69ca1eb61f4e4c7.tar.gz |
Fix compilation errors under C++11.
`std::string::data()` is const-only until C++17.
PiperOrigin-RevId: 479708109
-rw-r--r-- | snappy.cc | 2 | ||||
-rw-r--r-- | snappy_benchmark.cc | 2 | ||||
-rw-r--r-- | snappy_unittest.cc | 2 |
3 files changed, 3 insertions, 3 deletions
@@ -2041,7 +2041,7 @@ size_t CompressFromIOVec(const struct iovec* iov, size_t iov_cnt, std::string* compressed) { // Compute the number of bytes to be compressed. size_t uncompressed_length = 0; - for (int i = 0; i < iov_cnt; ++i) { + for (size_t i = 0; i < iov_cnt; ++i) { uncompressed_length += iov[i].iov_len; } diff --git a/snappy_benchmark.cc b/snappy_benchmark.cc index 0590142..28570dd 100644 --- a/snappy_benchmark.cc +++ b/snappy_benchmark.cc @@ -164,7 +164,7 @@ void BM_UIOVecSource(benchmark::State& state) { struct iovec iov[kNumEntries]; size_t used_so_far = 0; for (int i = 0; i < kNumEntries; ++i) { - iov[i].iov_base = contents.data() + used_so_far; + iov[i].iov_base = const_cast<char*>(contents.data()) + used_so_far; if (used_so_far == contents.size()) { iov[i].iov_len = 0; continue; diff --git a/snappy_unittest.cc b/snappy_unittest.cc index aeb8044..122be0c 100644 --- a/snappy_unittest.cc +++ b/snappy_unittest.cc @@ -170,7 +170,7 @@ struct iovec* GetIOVec(const std::string& input, char*& buf, size_t& num) { int VerifyIOVecSource(const std::string& input) { std::string compressed; std::string copy = input; - char* buf = copy.data(); + char* buf = const_cast<char*>(copy.data()); size_t num = 0; struct iovec* iov = GetIOVec(input, buf, num); const size_t written = snappy::CompressFromIOVec(iov, num, &compressed); |