Mercurial > vba-clojure
comparison src/win32/7zip/7z/C/7zCrc.c @ 1:f9f4f1b99eed
importing src directory
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 03 Mar 2012 10:31:27 -0600 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:8ced16adf2e1 | 1:f9f4f1b99eed |
---|---|
1 /* 7zCrc.c -- CRC32 calculation | |
2 2008-08-05 | |
3 Igor Pavlov | |
4 Public domain */ | |
5 | |
6 #include "7zCrc.h" | |
7 | |
8 #define kCrcPoly 0xEDB88320 | |
9 UInt32 g_CrcTable[256]; | |
10 | |
11 void MY_FAST_CALL CrcGenerateTable(void) | |
12 { | |
13 UInt32 i; | |
14 for (i = 0; i < 256; i++) | |
15 { | |
16 UInt32 r = i; | |
17 int j; | |
18 for (j = 0; j < 8; j++) | |
19 r = (r >> 1) ^ (kCrcPoly & ~((r & 1) - 1)); | |
20 g_CrcTable[i] = r; | |
21 } | |
22 } | |
23 | |
24 UInt32 MY_FAST_CALL CrcUpdate(UInt32 v, const void *data, size_t size) | |
25 { | |
26 const Byte *p = (const Byte *)data; | |
27 for (; size > 0 ; size--, p++) | |
28 v = CRC_UPDATE_BYTE(v, *p); | |
29 return v; | |
30 } | |
31 | |
32 UInt32 MY_FAST_CALL CrcCalc(const void *data, size_t size) | |
33 { | |
34 return CrcUpdate(CRC_INIT_VAL, data, size) ^ 0xFFFFFFFF; | |
35 } |