OLD | NEW |
1 /* | 1 /* |
2 bsdiff.c -- Binary patch generator. | 2 bsdiff.c -- Binary patch generator. |
3 | 3 |
4 Copyright 2003 Colin Percival | 4 Copyright 2003 Colin Percival |
5 | 5 |
6 For the terms under which this work may be distributed, please see | 6 For the terms under which this work may be distributed, please see |
7 the adjoining file "LICENSE". | 7 the adjoining file "LICENSE". |
8 | 8 |
9 ChangeLog: | 9 ChangeLog: |
10 2005-05-05 - Use the modified header struct from bspatch.h; use 32-bit | 10 2005-05-05 - Use the modified header struct from bspatch.h; use 32-bit |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 } | 417 } |
418 } | 418 } |
419 | 419 |
420 if (!diff_skips->WriteVarint32(pending_diff_zeros)) | 420 if (!diff_skips->WriteVarint32(pending_diff_zeros)) |
421 return MEM_ERROR; | 421 return MEM_ERROR; |
422 | 422 |
423 I.clear(); | 423 I.clear(); |
424 | 424 |
425 MBSPatchHeader header; | 425 MBSPatchHeader header; |
426 // The string will have a null terminator that we don't use, hence '-1'. | 426 // The string will have a null terminator that we don't use, hence '-1'. |
427 COMPILE_ASSERT(sizeof(MBS_PATCH_HEADER_TAG) - 1 == sizeof(header.tag), | 427 static_assert(sizeof(MBS_PATCH_HEADER_TAG) - 1 == sizeof(header.tag), |
428 MBS_PATCH_HEADER_TAG_must_match_header_field_size); | 428 "MBS_PATCH_HEADER_TAG must match header field size"); |
429 memcpy(header.tag, MBS_PATCH_HEADER_TAG, sizeof(header.tag)); | 429 memcpy(header.tag, MBS_PATCH_HEADER_TAG, sizeof(header.tag)); |
430 header.slen = oldsize; | 430 header.slen = oldsize; |
431 header.scrc32 = CalculateCrc(old, oldsize); | 431 header.scrc32 = CalculateCrc(old, oldsize); |
432 header.dlen = newsize; | 432 header.dlen = newsize; |
433 | 433 |
434 if (!WriteHeader(patch_stream, &header)) | 434 if (!WriteHeader(patch_stream, &header)) |
435 return MEM_ERROR; | 435 return MEM_ERROR; |
436 | 436 |
437 size_t diff_skips_length = diff_skips->Length(); | 437 size_t diff_skips_length = diff_skips->Length(); |
438 if (!patch_streams.CopyTo(patch_stream)) | 438 if (!patch_streams.CopyTo(patch_stream)) |
439 return MEM_ERROR; | 439 return MEM_ERROR; |
440 | 440 |
441 VLOG(1) << "Control tuples: " << control_length | 441 VLOG(1) << "Control tuples: " << control_length |
442 << " copy bytes: " << diff_bytes_length | 442 << " copy bytes: " << diff_bytes_length |
443 << " mistakes: " << diff_bytes_nonzero | 443 << " mistakes: " << diff_bytes_nonzero |
444 << " (skips: " << diff_skips_length << ")" | 444 << " (skips: " << diff_skips_length << ")" |
445 << " extra bytes: " << extra_bytes_length | 445 << " extra bytes: " << extra_bytes_length |
446 << "\nUncompressed bsdiff patch size " | 446 << "\nUncompressed bsdiff patch size " |
447 << patch_stream->Length() - initial_patch_stream_length | 447 << patch_stream->Length() - initial_patch_stream_length |
448 << "\nEnd bsdiff " | 448 << "\nEnd bsdiff " |
449 << (base::Time::Now() - start_bsdiff_time).InSecondsF(); | 449 << (base::Time::Now() - start_bsdiff_time).InSecondsF(); |
450 | 450 |
451 return OK; | 451 return OK; |
452 } | 452 } |
453 | 453 |
454 } // namespace | 454 } // namespace |
OLD | NEW |