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

Side by Side Diff: courgette/crc.cc

Issue 8763014: Use a different define to decide which CRC library to use. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Calculate Crc by calling CRC method in LZMA SDK
6
7 #include "courgette/crc.h" 5 #include "courgette/crc.h"
8 6
7 #ifdef COURGETTE_USE_CRC_LIB
8 # include "zlib.h"
9 #else
9 extern "C" { 10 extern "C" {
10 #include "third_party/lzma_sdk/7zCrc.h" 11 # include "third_party/lzma_sdk/7zCrc.h"
11 } 12 }
13 #endif
14
15 #include "base/basictypes.h"
12 16
13 namespace courgette { 17 namespace courgette {
14 18
15 uint32 CalculateCrc(const uint8* buffer, size_t size) { 19 uint32 CalculateCrc(const uint8* buffer, size_t size) {
20 uint32 crc;
21
22 #ifdef COURGETTE_USE_CRC_LIB
23 // Calculate Crc by calling CRC method in zlib
24 crc = crc32(0, buffer, size);
25 #else
26 // Calculate Crc by calling CRC method in LZMA SDK
16 CrcGenerateTable(); 27 CrcGenerateTable();
17 uint32 crc = 0xffffffffL; 28 crc = CrcCalc(buffer, size);
18 crc = ~CrcCalc(buffer, size); 29 #endif
19 return crc; 30
31 return ~crc;
20 } 32 }
21 33
22 } // namespace 34 } // namespace
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698