MCPcopy Create free account
hub / github.com/Tencent/Hardcoder / getCrc32

Function getCrc32

libapp2sys/src/main/cpp/util.h:183–206  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

181static unsigned int Crc32Table[256] = {0};
182
183static unsigned int getCrc32(uint8_t *data, uint32_t len) {
184 int i, j;
185 unsigned int Crc;
186 if (Crc32Table[0] == 0) { //create CRC32 table
187 for (i = 0; i < 256; i++) {
188 Crc = i;
189 for (j = 0; j < 8; j++) {
190 if (Crc & 1)
191 Crc = (Crc >> 1) ^ 0xEDB88320;
192 else
193 Crc >>= 1;
194 }
195 Crc32Table[i] = Crc;
196 }
197 }
198
199 Crc = 0xffffffff;
200 for (uint32_t i = 0; i < len; i++) {
201 Crc = (Crc >> 8) ^ Crc32Table[(Crc & 0xFF) ^ (data[i])];
202 }
203
204 Crc ^= 0xFFFFFFFF;
205 return Crc;
206}
207
208static char* getVersion(const char* str, const char* delims) {
209 if (str == NULL || delims == NULL) {

Callers 2

processReceiveMethod · 0.85
sendPackageMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected