Mercurial > vba-linux
view src/win32/7zip/7z/C/7zCrc.c @ 6:458a4f18f3cd
working on lua generation
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 03 Mar 2012 10:48:33 -0600 |
parents | f9f4f1b99eed |
children |
line wrap: on
line source
1 /* 7zCrc.c -- CRC32 calculation2 2008-08-053 Igor Pavlov4 Public domain */6 #include "7zCrc.h"8 #define kCrcPoly 0xEDB883209 UInt32 g_CrcTable[256];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 }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 }32 UInt32 MY_FAST_CALL CrcCalc(const void *data, size_t size)33 {34 return CrcUpdate(CRC_INIT_VAL, data, size) ^ 0xFFFFFFFF;35 }