X-Git-Url: http://git.joshuawise.com/netwatch.git/blobdiff_plain/2e581707f488e66ecce37a7343c813e071fd6beb..47d8a487f11a9780a9d9c4955c55e5b42edbbdfc:/lib/crc32.c?ds=inline diff --git a/lib/crc32.c b/lib/crc32.c index fd7bd49..a5512f6 100644 --- a/lib/crc32.c +++ b/lib/crc32.c @@ -3,17 +3,17 @@ /* code from http://www.faqs.org/faqs/compression-faq/part1/section-26.html, * presumed public domain */ -uint32_t crc32_table[256]; +static uint32_t crc32_table[256]; -uint32_t crc32(uint8_t *buf, int len) +uint32_t crc32(uint8_t *buf, int len, uint32_t crc0) { uint8_t *p; uint32_t crc; - crc = 0xffffffff; /* preload shift register, per CRC-32 spec */ + crc = crc0; for (p = buf; len > 0; ++p, --len) crc = (crc << 8) ^ crc32_table[(crc >> 24) ^ *p]; - return ~crc; /* transmit complement, per CRC-32 spec */ + return crc; } /*