diff options
author | zyp <zyp@localhost> | 2006-05-08 15:23:20 +0200 |
---|---|---|
committer | zyp <zyp@localhost> | 2006-05-08 15:23:20 +0200 |
commit | df9c15d40a50ed17baa7bdbb11ef6cca9d410cf3 (patch) | |
tree | 4ceb64d5c29e6bf487f8a6e7dde655a2c0b5f26a /crc32.cpp | |
parent | 3a5b32f44a95b989e39273527fc924ad3d32465e (diff) |
[project @ zyp-20060508132320-2c118d1a7e2505db]
[project @ 24]
Converted from make to distutils.
Diffstat (limited to 'crc32.cpp')
-rw-r--r-- | crc32.cpp | 41 |
1 files changed, 0 insertions, 41 deletions
diff --git a/crc32.cpp b/crc32.cpp deleted file mode 100644 index 55d6dd2..0000000 --- a/crc32.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include "crc32.h" - -int* CRC32::crc_table; - -int* CRC32::generate_table() { - int crc; - int* table = new int[256]; - for(int i = 0; i < 256; i++) { - crc = i << 24; - for(int j = 0; j < 8; j++) { - if(crc & 0x80000000) { - crc = (crc << 1) ^ 0x04c11db7; - } else { - crc = crc << 1; - } - } - table[i] = crc; - } - return table; -} - -int CRC32::reflect(int data, int bits) { - int x = 0; - for(int i = 0; i < bits; i++) { - x = x << 1; - x |= data & 1; - data = data >> 1; - } - return x; -} - -int CRC32::crc32(int crc, const char* data, int length) { - crc = ~reflect(crc, 32); - if(!crc_table) { - crc_table = generate_table(); - } - for (int i = 0; i < length; i++) { - crc = (crc << 8) ^ crc_table[((crc >> 24) ^ reflect(data[i], 8)) & 0xff]; - } - return ~reflect(crc, 32); -} |