mirror of https://github.com/google/snappy.git
Fix compilation errors under C++11.
`std::string::data()` is const-only until C++17. PiperOrigin-RevId: 479708109
This commit is contained in:
parent
d644ca8770
commit
974fcc49e8
|
@ -2041,7 +2041,7 @@ size_t CompressFromIOVec(const struct iovec* iov, size_t iov_cnt,
|
||||||
std::string* compressed) {
|
std::string* compressed) {
|
||||||
// Compute the number of bytes to be compressed.
|
// Compute the number of bytes to be compressed.
|
||||||
size_t uncompressed_length = 0;
|
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;
|
uncompressed_length += iov[i].iov_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -164,7 +164,7 @@ void BM_UIOVecSource(benchmark::State& state) {
|
||||||
struct iovec iov[kNumEntries];
|
struct iovec iov[kNumEntries];
|
||||||
size_t used_so_far = 0;
|
size_t used_so_far = 0;
|
||||||
for (int i = 0; i < kNumEntries; ++i) {
|
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()) {
|
if (used_so_far == contents.size()) {
|
||||||
iov[i].iov_len = 0;
|
iov[i].iov_len = 0;
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -170,7 +170,7 @@ struct iovec* GetIOVec(const std::string& input, char*& buf, size_t& num) {
|
||||||
int VerifyIOVecSource(const std::string& input) {
|
int VerifyIOVecSource(const std::string& input) {
|
||||||
std::string compressed;
|
std::string compressed;
|
||||||
std::string copy = input;
|
std::string copy = input;
|
||||||
char* buf = copy.data();
|
char* buf = const_cast<char*>(copy.data());
|
||||||
size_t num = 0;
|
size_t num = 0;
|
||||||
struct iovec* iov = GetIOVec(input, buf, num);
|
struct iovec* iov = GetIOVec(input, buf, num);
|
||||||
const size_t written = snappy::CompressFromIOVec(iov, num, &compressed);
|
const size_t written = snappy::CompressFromIOVec(iov, num, &compressed);
|
||||||
|
|
Loading…
Reference in New Issue