Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(256)

Unified Diff: courgette/third_party/bsdiff/bsdiff_create.cc

Issue 2031193002: [Courgette] Refactor BSDiff namespaces and bsdiff::search() interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make license style uniform; remove checklicenses.py entries. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: courgette/third_party/bsdiff/bsdiff_create.cc
diff --git a/courgette/third_party/bsdiff/bsdiff_create.cc b/courgette/third_party/bsdiff/bsdiff_create.cc
index 46a32b8bda8ac659ec3294f735a14716ebbd6382..0f713e937b4efdf2dbb6df7320ac42abb75db4c3 100644
--- a/courgette/third_party/bsdiff/bsdiff_create.cc
+++ b/courgette/third_party/bsdiff/bsdiff_create.cc
@@ -1,30 +1,42 @@
-/*
- bsdiff.c -- Binary patch generator.
-
- Copyright 2003 Colin Percival
-
- For the terms under which this work may be distributed, please see
- the adjoining file "LICENSE".
-
- ChangeLog:
- 2005-05-05 - Use the modified header struct from bspatch.h; use 32-bit
- values throughout.
- --Benjamin Smedberg <benjamin@smedbergs.us>
- 2005-05-18 - Use the same CRC algorithm as bzip2, and leverage the CRC table
- provided by libbz2.
- --Darin Fisher <darin@meer.net>
- 2007-11-14 - Changed to use Crc from Lzma library instead of Bzip library
- --Rahul Kuchhal
- 2009-03-31 - Change to use Streams. Added lots of comments.
- --Stephen Adams <sra@chromium.org>
- 2010-05-26 - Use a paged array for V and I. The address space may be too
- fragmented for these big arrays to be contiguous.
- --Stephen Adams <sra@chromium.org>
- 2015-08-03 - Extract qsufsort portion to a separate file.
- --Samuel Huang <huangs@chromium.org>
- 2015-08-12 - Interface change to qsufsort search().
- --Samuel Huang <huangs@chromium.org>
-*/
+// Copyright 2003, 2004 Colin Percival
+// All rights reserved
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted providing that the following conditions
+// are met:
+// 1. Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+//
+// For the terms under which this work may be distributed, please see
+// the adjoining file "LICENSE".
+//
+// bsdiff_create.c -- Binary patch generator.
+//
+// ChangeLog:
+// 2005-05-05 - Use the modified header struct from bspatch.h; use 32-bit
+// values throughout.
+// --Benjamin Smedberg <benjamin@smedbergs.us>
+// 2005-05-18 - Use the same CRC algorithm as bzip2, and leverage the CRC table
+// provided by libbz2.
+// --Darin Fisher <darin@meer.net>
+// 2007-11-14 - Changed to use Crc from Lzma library instead of Bzip library
+// --Rahul Kuchhal
+// 2009-03-31 - Change to use Streams. Added lots of comments.
+// --Stephen Adams <sra@chromium.org>
+// 2010-05-26 - Use a paged array for V and I. The address space may be too
+// fragmented for these big arrays to be contiguous.
+// --Stephen Adams <sra@chromium.org>
+// 2015-08-03 - Extract qsufsort portion to a separate file.
+// --Samuel Huang <huangs@chromium.org>
+// 2015-08-12 - Interface change to search().
+// --Samuel Huang <huangs@chromium.org>
+
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
#include "courgette/third_party/bsdiff/bsdiff.h"
@@ -39,10 +51,22 @@
#include "courgette/crc.h"
#include "courgette/streams.h"
+#include "courgette/third_party/bsdiff/bsdiff_search.h"
#include "courgette/third_party/bsdiff/paged_array.h"
#include "courgette/third_party/bsdiff/qsufsort.h"
-namespace courgette {
+namespace {
+
+using courgette::CalculateCrc;
+using courgette::PagedArray;
+using courgette::SinkStream;
+using courgette::SinkStreamSet;
+using courgette::SourceStream;
+using courgette::SourceStreamSet;
+
+} // namespace
+
+namespace bsdiff {
static CheckBool WriteHeader(SinkStream* stream, MBSPatchHeader* header) {
bool ok = stream->Write(header->tag, sizeof(header->tag));
@@ -151,7 +175,7 @@ BSDiffStatus CreateBinaryPatch(SourceStream* old_stream,
scan += match_length;
for (int scsc = scan; scan < newsize; ++scan) {
- match_length = qsuf::search<PagedArray<int>&>(
+ match_length = search<PagedArray<int>&>(
I, old, oldsize, newbuf + scan, newsize - scan, &pos);
for (; scsc < scan + match_length; scsc++)
@@ -316,4 +340,4 @@ BSDiffStatus CreateBinaryPatch(SourceStream* old_stream,
return OK;
}
-} // namespace courgette
+} // namespace bsdiff

Powered by Google App Engine
This is Rietveld 408576698