// Copyright (c) 2011 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/crc.h"

#ifdef COURGETTE_USE_CRC_LIB
#  include "zlib.h"
#else
extern "C" {
#  include "third_party/lzma_sdk/7zCrc.h"
}
#endif

#include "base/basictypes.h"

namespace courgette {

uint32 CalculateCrc(const uint8* buffer, size_t size) {
  uint32 crc;

#ifdef COURGETTE_USE_CRC_LIB
  // Calculate Crc by calling CRC method in zlib
  crc = crc32(0, buffer, size);
#else
  // Calculate Crc by calling CRC method in LZMA SDK
  CrcGenerateTable();
  crc = CrcCalc(buffer, size);
#endif

  return ~crc;
}

}  // namespace

// Copyright (c) 2009 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.

// Calculate Crc by calling CRC method in LZMA SDK

#include "courgette/crc.h"

extern "C" {
#include "third_party/lzma_sdk/7zCrc.h"
}

namespace courgette {

uint32 CalculateCrc(const uint8* buffer, size_t size) {
  CrcGenerateTable();
  uint32 crc = 0xffffffffL;
  crc = ~CrcCalc(buffer, size);
  return crc;
}

}  // namespace

--- 
+++ 
@@ -1,22 +1,34 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
 
-// Calculate Crc by calling CRC method in LZMA SDK
-
 #include "courgette/crc.h"
 
+#ifdef COURGETTE_USE_CRC_LIB
+#  include "zlib.h"
+#else
 extern "C" {
-#include "third_party/lzma_sdk/7zCrc.h"
+#  include "third_party/lzma_sdk/7zCrc.h"
 }
+#endif
+
+#include "base/basictypes.h"
 
 namespace courgette {
 
 uint32 CalculateCrc(const uint8* buffer, size_t size) {
+  uint32 crc;
+
+#ifdef COURGETTE_USE_CRC_LIB
+  // Calculate Crc by calling CRC method in zlib
+  crc = crc32(0, buffer, size);
+#else
+  // Calculate Crc by calling CRC method in LZMA SDK
   CrcGenerateTable();
-  uint32 crc = 0xffffffffL;
-  crc = ~CrcCalc(buffer, size);
-  return crc;
+  crc = CrcCalc(buffer, size);
+#endif
+
+  return ~crc;
 }
 
 }  // namespace
Use a different define to decide which CRC library to use.

Change 8569018 used a #ifdef to conditionally decide which external
library to use for Crc calculation. It used OS_CHROMIUMOS to tell
if the build was targetted at Chromium OS.

However, it broke Chromium OS builds of the full Chromium tree in
some cases (heapcheck bots), and was reverted.

Since I really only want to change the library when building from
inside a custom ebuild in the Chromium OS build, it makes sense
to use a #define custom to that ebuild.

So, this change is the same as 8569018, except that is uses
COURGETTE_USE_CRC_LIB instead of OS_CHROMIUMOS.

BUG=8569018


Review URL: http://codereview.chromium.org/8763014

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@112565 0039d316-1c4b-4281-b951-d872f2087c98
