a
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
// Crc32.cpp: implementation of the Crc32 class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "Crc32.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[]=__FILE__;
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Crc32::Crc32()
|
||||
// {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// Crc32::~Crc32()
|
||||
// {
|
||||
//
|
||||
// }
|
||||
|
||||
unsigned long Crc32::table[ 256 ];
|
||||
int Crc32::initialized = 0;
|
||||
|
||||
Crc32::Crc32( unsigned long init_value )
|
||||
{
|
||||
if ( !initialized ) {
|
||||
int i;
|
||||
int j;
|
||||
unsigned long coeff;
|
||||
|
||||
for ( i = 0; i < 256 ; i++ ) {
|
||||
coeff = i;
|
||||
for ( j = 0; j < 8; j++ ) {
|
||||
if ( coeff & 1 )
|
||||
coeff = ( coeff >> 1 ) ^ 0xEDB88320L;
|
||||
else
|
||||
coeff >>= 1;
|
||||
}
|
||||
table[ i ] = coeff;
|
||||
}
|
||||
initialized = 1;
|
||||
}
|
||||
crc = init_value;
|
||||
}
|
||||
Reference in New Issue
Block a user