mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-17 22:50:51 +00:00
break the loop from CRC_Block into CRC_ProcessBlock so that crcs can be
caclulated over multiple blocks.
This commit is contained in:
parent
21b6e68a8c
commit
6f29bcb238
2 changed files with 12 additions and 4 deletions
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue