CMS 3D CMS Logo

Adler32Calculator.cc
Go to the documentation of this file.
2 
3 namespace cms {
4 
5  //-------------------------------------------------------
6  // the following is adapted from
7  // http://en.wikipedia.org/wiki/Adler-32
8  //-------------------------------------------------------
9 
10  void Adler32(char const* data, size_t len, uint32_t& a, uint32_t& b) {
11  /* data: Pointer to the data to be summed; len is in bytes */
12 
13 #define MOD_ADLER 65521
14 
15  unsigned char const* ptr = static_cast<unsigned char const*>(static_cast<void const*>(data));
16  while (len > 0) {
17  size_t tlen = (len > 5552 ? 5552 : len);
18  len -= tlen;
19  do {
20  a += *ptr++;
21  b += a;
22  } while (--tlen);
23 
24  a %= MOD_ADLER;
25  b %= MOD_ADLER;
26  }
27 
28 #undef MOD_ADLER
29  }
30 
31  uint32_t Adler32(char const* data, size_t len) {
32  /* data: Pointer to the data to be summed; len is in bytes */
33  uint32_t a = 1, b = 0;
34  Adler32(data, len, a, b);
35  return (b << 16) | a;
36  }
37 } // namespace cms
Namespace of DDCMS conversion namespace.
void Adler32(char const *data, size_t len, uint32_t &a, uint32_t &b)
double b
Definition: hdecay.h:120
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
double a
Definition: hdecay.h:121
#define MOD_ADLER