Mercurial > wgsdk
diff src/utils.c @ 9:07f0e2f43204
*: add the restrict keyword when necessary
also fixed some typos in the README
author | Paper |
---|---|
date | Fri, 16 Dec 2022 21:55:37 -0500 |
parents | be4835547dd0 |
children | 42ac054c0231 |
line wrap: on
line diff
--- a/src/utils.c Fri Dec 16 20:46:33 2022 -0500 +++ b/src/utils.c Fri Dec 16 21:55:37 2022 -0500 @@ -16,20 +16,18 @@ return ((ul - 116444736000000000ULL)/10000000); } -unsigned int crc32b(unsigned char *message) { - int i, j; - unsigned int byte, crc, mask; +uint32_t crc32b(unsigned char* restrict message) { + int32_t i, j; + uint32_t byte, crc, mask; - i = 0; crc = 0xFFFFFFFF; - while (message[i] != 0) { + for (i = 0; message[i] != 0; i++) { byte = message[i]; // Get next byte. crc = crc ^ byte; for (j = 7; j >= 0; j--) { // Do eight times. mask = -(crc & 1); crc = (crc >> 1) ^ (0xEDB88320 & mask); } - i = i + 1; } return ~crc; }