mirror of
https://github.com/expo/bsdiff.git
synced 2026-11-13 20:11:27 -10:00
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
This commit is contained in:
commit
e6302e4498
4 files changed
+17
-14
No files matched your search
File renamed without changes.
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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:
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in new issue
Block a user