7 static const UInt32 kCRCPoly
= 0xEDB88320;
9 UInt32
CCRC::Table
[256];
11 void CCRC::InitTable()
13 for (UInt32 i
= 0; i
< 256; i
++)
16 for (int j
= 0; j
< 8; j
++)
18 r
= (r
>> 1) ^ kCRCPoly
;
28 CCRCTableInit() { CCRC::InitTable(); }
31 void CCRC::UpdateByte(Byte b
)
33 _value
= Table
[((Byte
)(_value
)) ^ b
] ^ (_value
>> 8);
36 void CCRC::UpdateUInt16(UInt16 v
)
39 UpdateByte(Byte(v
>> 8));
42 void CCRC::UpdateUInt32(UInt32 v
)
44 for (int i
= 0; i
< 4; i
++)
45 UpdateByte((Byte
)(v
>> (8 * i
)));
48 void CCRC::UpdateUInt64(UInt64 v
)
50 for (int i
= 0; i
< 8; i
++)
51 UpdateByte((Byte
)(v
>> (8 * i
)));
54 void CCRC::Update(const void *data
, size_t size
)
57 const Byte
*p
= (const Byte
*)data
;
58 for (; size
> 0 ; size
--, p
++)
59 v
= Table
[((Byte
)(v
)) ^ *p
] ^ (v
>> 8);