summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKelvin Zhang <zhangkelvin@google.com>2021-07-24 01:18:37 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2021-07-24 01:18:37 +0000
commite6302e44989f911ba2f7d8bed444cd112fe065b1 (patch)
tree7a09dff0a55fec57ae1ba55d023b5deae612d4fb
parent4f8b7fb2b3e3b3d492568931d241c6b14ac3bd6b (diff)
parentf7c65e157b50f599ef328026291c2d4b18fac68f (diff)
downloadbsdiff-e6302e44989f911ba2f7d8bed444cd112fe065b1.tar.gz
Merge "Expose PatchWriter for consumption" am: c1c7b9eaa7 am: 5ecdc7df3c am: f7c65e157b
Original change: https://android-review.googlesource.com/c/platform/external/bsdiff/+/1768592 Change-Id: I859e757c054c317cec9dccfb423975b21ab5497b
-rw-r--r--include/bsdiff/compressor_interface.h (renamed from compressor_interface.h)0
-rw-r--r--include/bsdiff/control_entry.h15
-rw-r--r--include/bsdiff/patch_writer.h (renamed from patch_writer.h)9
-rw-r--r--patch_writer.cc7
4 files changed, 17 insertions, 14 deletions
diff --git a/compressor_interface.h b/include/bsdiff/compressor_interface.h
index c0ff18d..c0ff18d 100644
--- a/compressor_interface.h
+++ b/include/bsdiff/compressor_interface.h
diff --git a/include/bsdiff/control_entry.h b/include/bsdiff/control_entry.h
index 2c849f6..3d2d96c 100644
--- a/include/bsdiff/control_entry.h
+++ b/include/bsdiff/control_entry.h
@@ -8,23 +8,24 @@
#include <stdint.h>
struct ControlEntry {
- ControlEntry(uint64_t diff_size,
- uint64_t extra_size,
- int64_t offset_increment)
+ constexpr ControlEntry(uint64_t diff_size,
+ uint64_t extra_size,
+ int64_t offset_increment)
: diff_size(diff_size),
extra_size(extra_size),
offset_increment(offset_increment) {}
+ constexpr ControlEntry() = default;
// The number of bytes to copy from the source and diff stream.
- uint64_t diff_size;
+ uint64_t diff_size{0};
// The number of bytes to copy from the extra stream.
- uint64_t extra_size;
+ uint64_t extra_size{0};
// The value to add to the source pointer after patching from the diff stream.
- int64_t offset_increment;
+ int64_t offset_increment{0};
- bool operator==(const ControlEntry& o) const {
+ [[nodiscard]] bool operator==(const ControlEntry& o) const {
return diff_size == o.diff_size && extra_size == o.extra_size &&
offset_increment == o.offset_increment;
}
diff --git a/patch_writer.h b/include/bsdiff/patch_writer.h
index 8ad4cde..6d2bcf5 100644
--- a/patch_writer.h
+++ b/include/bsdiff/patch_writer.h
@@ -14,6 +14,15 @@
namespace bsdiff {
+
+constexpr void EncodeInt64(int64_t x, uint8_t* buf) {
+ uint64_t y = x < 0 ? (1ULL << 63ULL) - x : x;
+ for (int i = 0; i < 8; ++i) {
+ buf[i] = y & 0xff;
+ y /= 256;
+ }
+}
+
// A PatchWriterInterface class with three compressors and a 32-byte header.
class BsdiffPatchWriter : public PatchWriterInterface {
public:
diff --git a/patch_writer.cc b/patch_writer.cc
index 52982e0..b7d9b08 100644
--- a/patch_writer.cc
+++ b/patch_writer.cc
@@ -15,13 +15,6 @@
namespace {
-void EncodeInt64(int64_t x, uint8_t* buf) {
- uint64_t y = x < 0 ? (1ULL << 63ULL) - x : x;
- for (int i = 0; i < 8; ++i) {
- buf[i] = y & 0xff;
- y /= 256;
- }
-}
} // namespace