4
4
5
5
#include " third_party/zlib/google/compression_utils.h"
6
6
7
- #include " base/bit_cast.h"
8
7
#include " base/check_op.h"
9
8
#include " base/process/memory.h"
10
9
#include " base/sys_byteorder.h"
@@ -24,8 +23,8 @@ bool GzipCompress(base::span<const char> input,
24
23
// uLongf can be larger than size_t.
25
24
uLongf compressed_size_long = static_cast <uLongf>(output_buffer_size);
26
25
if (zlib_internal::GzipCompressHelper (
27
- base::bit_cast <Bytef*>(output_buffer), &compressed_size_long,
28
- base::bit_cast <const Bytef*>(input.data ()),
26
+ reinterpret_cast <Bytef*>(output_buffer), &compressed_size_long,
27
+ reinterpret_cast <const Bytef*>(input.data ()),
29
28
static_cast <uLongf>(input.size ()), malloc_fn, free_fn) != Z_OK) {
30
29
return false ;
31
30
}
@@ -55,7 +54,7 @@ bool GzipCompress(base::span<const uint8_t> input, std::string* output) {
55
54
56
55
if (zlib_internal::GzipCompressHelper (
57
56
compressed_data, &compressed_data_size,
58
- base::bit_cast <const Bytef*>(input.data ()), input_size, nullptr ,
57
+ reinterpret_cast <const Bytef*>(input.data ()), input_size, nullptr ,
59
58
nullptr ) != Z_OK) {
60
59
free (compressed_data);
61
60
return false ;
@@ -82,8 +81,8 @@ bool GzipUncompress(const std::string& input, std::string* output) {
82
81
83
82
uncompressed_output.resize (uncompressed_size);
84
83
if (zlib_internal::GzipUncompressHelper (
85
- base::bit_cast <Bytef*>(uncompressed_output.data ()),
86
- &uncompressed_size, base::bit_cast <const Bytef*>(input.data ()),
84
+ reinterpret_cast <Bytef*>(uncompressed_output.data ()),
85
+ &uncompressed_size, reinterpret_cast <const Bytef*>(input.data ()),
87
86
static_cast <uLongf>(input.length ())) == Z_OK) {
88
87
output->swap (uncompressed_output);
89
88
return true ;
@@ -102,8 +101,8 @@ bool GzipUncompress(base::span<const uint8_t> input,
102
101
if (uncompressed_size > output.size ())
103
102
return false ;
104
103
return zlib_internal::GzipUncompressHelper (
105
- base::bit_cast <Bytef*>(output.data ()), &uncompressed_size ,
106
- base::bit_cast <const Bytef*>(input.data ()),
104
+ reinterpret_cast <Bytef*>(const_cast < uint8_t *>( output.data ())) ,
105
+ &uncompressed_size, reinterpret_cast <const Bytef*>(input.data ()),
107
106
static_cast <uLongf>(input.size ())) == Z_OK;
108
107
}
109
108
@@ -117,8 +116,8 @@ bool GzipUncompress(base::span<const uint8_t> input, std::string* output) {
117
116
uLongf uncompressed_size = GetUncompressedSize (input);
118
117
output->resize (uncompressed_size);
119
118
return zlib_internal::GzipUncompressHelper (
120
- base::bit_cast <Bytef*>(output->data ()), &uncompressed_size,
121
- base::bit_cast <const Bytef*>(input.data ()),
119
+ reinterpret_cast <Bytef*>(output->data ()), &uncompressed_size,
120
+ reinterpret_cast <const Bytef*>(input.data ()),
122
121
static_cast <uLongf>(input.size ())) == Z_OK;
123
122
}
124
123
@@ -128,7 +127,8 @@ uint32_t GetUncompressedSize(base::span<const char> compressed_data) {
128
127
129
128
uint32_t GetUncompressedSize (base::span<const uint8_t > compressed_data) {
130
129
return zlib_internal::GetGzipUncompressedSize (
131
- base::bit_cast<Bytef*>(compressed_data.data ()), compressed_data.size ());
130
+ reinterpret_cast <const Bytef*>(compressed_data.data ()),
131
+ compressed_data.size ());
132
132
}
133
133
134
134
} // namespace compression
0 commit comments