MCPcopy Create free account
hub / github.com/abbeycode/UnrarKit / CRC32

Function CRC32

Libraries/unrar/crc.cpp:54–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52struct CallInitCRC {CallInitCRC() {InitTables();}} static CallInit32;
53
54uint CRC32(uint StartCRC,const void *Addr,size_t Size)
55{
56 byte *Data=(byte *)Addr;
57
58 // Align Data to 8 for better performance.
59 for (;Size>0 && ((size_t)Data & 7);Size--,Data++)
60 StartCRC=crc_tables[0][(byte)(StartCRC^Data[0])]^(StartCRC>>8);
61
62 for (;Size>=8;Size-=8,Data+=8)
63 {
64#ifdef BIG_ENDIAN
65 StartCRC ^= Data[0]|(Data[1] << 8)|(Data[2] << 16)|(Data[3] << 24);
66 uint NextData = Data[4]|(Data[5] << 8)|(Data[6] << 16)|(Data[7] << 24);
67#else
68 StartCRC ^= *(uint32 *) Data;
69 uint NextData = *(uint32 *) (Data+4);
70#endif
71 StartCRC = crc_tables[7][(byte) StartCRC ] ^
72 crc_tables[6][(byte)(StartCRC >> 8) ] ^
73 crc_tables[5][(byte)(StartCRC >> 16)] ^
74 crc_tables[4][(byte)(StartCRC >> 24)] ^
75 crc_tables[3][(byte) NextData ] ^
76 crc_tables[2][(byte)(NextData >> 8) ] ^
77 crc_tables[1][(byte)(NextData >> 16)] ^
78 crc_tables[0][(byte)(NextData >> 24)];
79 }
80
81 for (;Size>0;Size--,Data++) // Process left data.
82 StartCRC=crc_tables[0][(byte)(StartCRC^Data[0])]^(StartCRC>>8);
83
84 return StartCRC;
85}
86
87
88#ifndef SFX_MODULE

Callers 7

SetKey15Method · 0.85
PrepareMethod · 0.85
ReadHeaderMethod · 0.85
UpdateMethod · 0.85
DoGetCommentMethod · 0.85
GetCRC15Method · 0.85
GetCRC50Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected