From 6f29bcb238b0b78f3ce693ebbc08adb673c3983e Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Mon, 28 Jan 2002 18:00:48 +0000 Subject: [PATCH] break the loop from CRC_Block into CRC_ProcessBlock so that crcs can be caclulated over multiple blocks. --- include/QF/crc.h | 1 + libs/util/crc.c | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/include/QF/crc.h b/include/QF/crc.h index 6c1dcba85..79be2c028 100644 --- a/include/QF/crc.h +++ b/include/QF/crc.h @@ -33,6 +33,7 @@ void CRC_Init(unsigned short *crcvalue); void CRC_ProcessByte(unsigned short *crcvalue, byte data); +void CRC_ProcessBlock (byte *start, unsigned short *crcvalue, int count); unsigned short CRC_Value(unsigned short crcvalue); unsigned short CRC_Block (byte *start, int count); diff --git a/libs/util/crc.c b/libs/util/crc.c index e47782a78..63232b29f 100644 --- a/libs/util/crc.c +++ b/libs/util/crc.c @@ -88,6 +88,15 @@ CRC_ProcessByte (unsigned short *crcvalue, byte data) *crcvalue = (*crcvalue << 8) ^ crctable[(*crcvalue >> 8) ^ data]; } +void +CRC_ProcessBlock (byte *start, unsigned short *crcvalue, int count) +{ + unsigned short crc = *crcvalue; + while (count--) + crc = (crc << 8) ^ crctable[(crc >> 8) ^ *start++]; + *crcvalue = crc; +} + unsigned short CRC_Value (unsigned short crcvalue) { @@ -95,13 +104,11 @@ CRC_Value (unsigned short crcvalue) } unsigned short -CRC_Block (byte * start, int count) +CRC_Block (byte *start, int count) { unsigned short crc; CRC_Init (&crc); - while (count--) - crc = (crc << 8) ^ crctable[(crc >> 8) ^ *start++]; - + CRC_ProcessBlock (start, &crc, count); return crc; }