CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
11  Adler32(char const* data, size_t len, uint32_t& a, uint32_t& b) {
12  /* data: Pointer to the data to be summed; len is in bytes */
13 
14  #define MOD_ADLER 65521
15 
16  unsigned char const* ptr = static_cast<unsigned char const*>(static_cast<void const*>(data));
17  while (len > 0) {
18  size_t tlen = (len > 5552 ? 5552 : len);
19  len -= tlen;
20  do {
21  a += *ptr++;
22  b += a;
23  } while (--tlen);
24 
25  a %= MOD_ADLER;
26  b %= MOD_ADLER;
27  }
28 
29  #undef MOD_ADLER
30  }
31 
32  uint32_t
33  Adler32(char const* data, size_t len) {
34  /* data: Pointer to the data to be summed; len is in bytes */
35  uint32_t a = 1, b = 0;
36  Adler32(data, len, a, b);
37  return (b << 16) | a;
38  }
39 }
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:82
double a
Definition: hdecay.h:121
#define MOD_ADLER