break the loop from CRC_Block into CRC_ProcessBlock so that crcs can be

caclulated over multiple blocks.
This commit is contained in:
Bill Currie 2002-01-28 18:00:48 +00:00
parent 21b6e68a8c
commit 6f29bcb238
2 changed files with 12 additions and 4 deletions

View file

@ -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);

View file

@ -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;
}