1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // A wrapper around ZLib's CRC functions to put them in the rlz_lib namespace
8 #include "rlz/lib/assert.h"
9 #include "rlz/lib/crc32.h"
10 #include "rlz/lib/string_utils.h"
11 #include "third_party/zlib/zlib.h"
15 int Crc32(const unsigned char* buf
, int length
) {
16 return crc32(0L, buf
, length
);
19 bool Crc32(const char* text
, int* crc
) {
21 ASSERT_STRING("Crc32: crc is NULL.");
26 for (int i
= 0; text
[i
]; i
++) {
27 if (!IsAscii(text
[i
]))
30 *crc
= crc32(*crc
, reinterpret_cast<const unsigned char*>(text
+ i
), 1);
36 } // namespace rlz_lib