blob: 75bad7df8e657138160983a4d041f603619fbe6f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
// --------------------------------------------------------------------------
//
// File
// Name: RollingChecksum.cpp
// Purpose: A simple rolling checksum over a block of data
// Created: 6/12/03
//
// --------------------------------------------------------------------------
#include "Box.h"
#include "RollingChecksum.h"
#include "MemLeakFindOn.h"
// --------------------------------------------------------------------------
//
// Function
// Name: RollingChecksum::RollingChecksum(const void *, unsigned int)
// Purpose: Constructor -- does initial computation of the checksum.
// Created: 6/12/03
//
// --------------------------------------------------------------------------
RollingChecksum::RollingChecksum(const void *data, unsigned int Length)
: a(0),
b(0)
{
uint8_t *block = (uint8_t *)data;
for(unsigned int x = Length; x >= 1; --x)
{
a += (*block);
b += x * (*block);
++block;
}
}
|