| OLD | NEW |
| (Empty) |
| 1 // Copyright 2008 Google Inc. | |
| 2 // Author: Lincoln Smith | |
| 3 // | |
| 4 // Licensed under the Apache License, Version 2.0 (the "License"); | |
| 5 // you may not use this file except in compliance with the License. | |
| 6 // You may obtain a copy of the License at | |
| 7 // | |
| 8 // http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 // | |
| 10 // Unless required by applicable law or agreed to in writing, software | |
| 11 // distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 // See the License for the specific language governing permissions and | |
| 14 // limitations under the License. | |
| 15 // | |
| 16 // A wrapper for the adler32() function from zlib. This can be replaced | |
| 17 // with another checksum implementation if desired. | |
| 18 | |
| 19 #ifndef OPEN_VCDIFF_CHECKSUM_H_ | |
| 20 #define OPEN_VCDIFF_CHECKSUM_H_ | |
| 21 | |
| 22 #include <config.h> | |
| 23 #include "zlib.h" | |
| 24 | |
| 25 namespace open_vcdiff { | |
| 26 | |
| 27 typedef uLong VCDChecksum; | |
| 28 | |
| 29 const VCDChecksum kNoPartialChecksum = 0; | |
| 30 | |
| 31 inline VCDChecksum ComputeAdler32(const char* buffer, | |
| 32 size_t size) { | |
| 33 return adler32(kNoPartialChecksum, | |
| 34 reinterpret_cast<const Bytef*>(buffer), | |
| 35 static_cast<uInt>(size)); | |
| 36 } | |
| 37 | |
| 38 inline VCDChecksum UpdateAdler32(VCDChecksum partial_checksum, | |
| 39 const char* buffer, | |
| 40 size_t size) { | |
| 41 return adler32(partial_checksum, | |
| 42 reinterpret_cast<const Bytef*>(buffer), | |
| 43 static_cast<uInt>(size)); | |
| 44 } | |
| 45 | |
| 46 } // namespace open_vcdiff | |
| 47 | |
| 48 #endif // OPEN_VCDIFF_CHECKSUM_H_ | |
| OLD | NEW |