From: Wolfgang (Blub) Bumiller Date: Tue, 2 Oct 2012 15:56:59 +0000 (+0200) Subject: Add the actual crc implementation X-Git-Tag: 0.1-rc1~25 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=c024cbaaa0c2006ca2fb769c7c54f6b139d38432;p=xonotic%2Fgmqcc.git Add the actual crc implementation --- diff --git a/util.c b/util.c index 8642f8b..bdc3f0f 100644 --- a/util.c +++ b/util.c @@ -338,11 +338,11 @@ static const uint16_t util_crc16_table[] = { * Quake expects a non-reflective CRC. */ #define CRC(X) \ -uint##X##_t util_crc##X(const char *k, int len, const short clamp) { \ - register uint##X##_t h= (uint##X##_t)0xFFFFFFFF; \ +uint##X##_t util_crc##X(uint##X##_t current, const char *k, size_t len) { \ + register uint##X##_t h= current; \ for (; len; --len, ++k) \ - h = util_crc##X##_table[(h^((unsigned char)*k))&0xFF]^(h>>8); \ - return (~h)%clamp; \ + h = util_crc##X##_table[(h>>8)^((unsigned char)*k)]^(h<<8); \ + return h; \ } CRC(32) CRC(16)