ClickHouse/base/poco/Foundation/src/Checksum.cpp
Robert Schulze b79ead9c84
Move poco to base/poco/ (#46075)
* Replicate poco into base/poco/

* De-register poco submodule

* Build poco from ClickHouse

* Exclude poco from stylecheck

* Exclude poco from whitespace check

* Exclude poco from typo check

* Remove x bit from sources/headers (the style check complained)

* Exclude poco from duplicate include check

* Fix fasttest

* Remove contrib/poco-cmake/*

* Simplify poco build descriptions

* Remove poco stuff not used by ClickHouse

* Glob poco sources

* Exclude poco from clang-tidy
2023-02-08 12:04:11 +01:00

59 lines
872 B
C++

//
// Checksum.cpp
//
// Library: Foundation
// Package: Core
// Module: Checksum
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/Checksum.h"
#if defined(POCO_UNBUNDLED)
#include <zlib.h>
#else
#include "Poco/zlib.h"
#endif
namespace Poco {
Checksum::Checksum():
_type(TYPE_CRC32),
_value(crc32(0L, Z_NULL, 0))
{
}
Checksum::Checksum(Type t):
_type(t),
_value(0)
{
if (t == TYPE_CRC32)
_value = crc32(0L, Z_NULL, 0);
else
_value = adler32(0L, Z_NULL, 0);
}
Checksum::~Checksum()
{
}
void Checksum::update(const char* data, unsigned length)
{
if (_type == TYPE_ADLER32)
_value = adler32(_value, reinterpret_cast<const Bytef*>(data), length);
else
_value = crc32(_value, reinterpret_cast<const Bytef*>(data), length);
}
} // namespace Poco