update_engine: replace std::vector<char> with chromeos::Blob
To make update engine consistent with the rest of platform2 code
replaced std::vector<char> as the container of binary data with
chromeos::Blob.
BUG=None
TEST=`FEATURES=test emerge-link update_engine`
Change-Id: I6385fd2257d15aa24bfa74ac35512c2a06c33012
Reviewed-on: https://chromium-review.googlesource.com/247793
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Alex Deymo <deymo@chromium.org>
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
diff --git a/bzip_extent_writer.cc b/bzip_extent_writer.cc
index 7cde7ba..14a0f63 100644
--- a/bzip_extent_writer.cc
+++ b/bzip_extent_writer.cc
@@ -9,7 +9,7 @@
namespace chromeos_update_engine {
namespace {
-const vector<char>::size_type kOutputBufferLength = 16 * 1024;
+const chromeos::Blob::size_type kOutputBufferLength = 16 * 1024;
}
bool BzipExtentWriter::Init(FileDescriptorPtr fd,
@@ -26,23 +26,23 @@
}
bool BzipExtentWriter::Write(const void* bytes, size_t count) {
- vector<char> output_buffer(kOutputBufferLength);
+ chromeos::Blob output_buffer(kOutputBufferLength);
// Copy the input data into |input_buffer_| only if |input_buffer_| already
// contains unconsumed data. Otherwise, process the data directly from the
// source.
- const char* input = reinterpret_cast<const char*>(bytes);
- const char* input_end = input + count;
+ const uint8_t* input = reinterpret_cast<const uint8_t*>(bytes);
+ const uint8_t* input_end = input + count;
if (!input_buffer_.empty()) {
input_buffer_.insert(input_buffer_.end(), input, input_end);
- input = &input_buffer_[0];
+ input = input_buffer_.data();
input_end = input + input_buffer_.size();
}
- stream_.next_in = const_cast<char*>(input);
+ stream_.next_in = reinterpret_cast<char*>(const_cast<uint8_t*>(input));
stream_.avail_in = input_end - input;
for (;;) {
- stream_.next_out = &output_buffer[0];
+ stream_.next_out = reinterpret_cast<char*>(output_buffer.data());
stream_.avail_out = output_buffer.size();
int rc = BZ2_bzDecompress(&stream_);
@@ -52,18 +52,18 @@
break; // got no new bytes
TEST_AND_RETURN_FALSE(
- next_->Write(&output_buffer[0],
+ next_->Write(output_buffer.data(),
output_buffer.size() - stream_.avail_out));
if (rc == BZ_STREAM_END)
- CHECK_EQ(stream_.avail_in, static_cast<unsigned int>(0));
+ CHECK_EQ(stream_.avail_in, 0u);
if (stream_.avail_in == 0)
break; // no more input to process
}
// Store unconsumed data (if any) in |input_buffer_|.
if (stream_.avail_in || !input_buffer_.empty()) {
- vector<char> new_input_buffer(input_end - stream_.avail_in, input_end);
+ chromeos::Blob new_input_buffer(input_end - stream_.avail_in, input_end);
new_input_buffer.swap(input_buffer_);
}