misc/libphysfs/lzma/C/7zCrc.c
changeset 13904 99b265e0d1d0
parent 13903 5f819b90d479
child 13905 b172a5d40eee
equal deleted inserted replaced
13903:5f819b90d479 13904:99b265e0d1d0
     1 /* 7zCrc.c */
       
     2 
       
     3 #include "7zCrc.h"
       
     4 
       
     5 #define kCrcPoly 0xEDB88320
       
     6 UInt32 g_CrcTable[256];
       
     7 
       
     8 void MY_FAST_CALL CrcGenerateTable(void)
       
     9 {
       
    10   UInt32 i;
       
    11   for (i = 0; i < 256; i++)
       
    12   {
       
    13     UInt32 r = i;
       
    14     int j;
       
    15     for (j = 0; j < 8; j++)
       
    16       r = (r >> 1) ^ (kCrcPoly & ~((r & 1) - 1));
       
    17     g_CrcTable[i] = r;
       
    18   }
       
    19 }
       
    20 
       
    21 UInt32 MY_FAST_CALL CrcUpdate(UInt32 v, const void *data, size_t size)
       
    22 {
       
    23   const Byte *p = (const Byte *)data;
       
    24   for (; size > 0 ; size--, p++) 
       
    25     v = CRC_UPDATE_BYTE(v, *p);
       
    26   return v;
       
    27 }
       
    28 
       
    29 UInt32 MY_FAST_CALL CrcCalc(const void *data, size_t size)
       
    30 {
       
    31   return CrcUpdate(CRC_INIT_VAL, data, size) ^ 0xFFFFFFFF;
       
    32 }