fixed bug #1504758 - CRC32 implementation use potentially non-32bit types

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@4697 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2006-06-16 14:12:04 +00:00
parent 618331287c
commit 3e561714e4
7 changed files with 38 additions and 30 deletions

View file

@ -1,20 +1,21 @@
#include "Platform.h"
#include "crc32.h"
#include "exehead/config.h"
#ifdef NSIS_CONFIG_CRC_SUPPORT
// this is based on the (slow,small) CRC32 implementation from zlib.
unsigned long NSISCALL CRC32(unsigned long crc, const unsigned char *buf, unsigned int len)
crc32_t NSISCALL CRC32(crc32_t crc, const unsigned char *buf, unsigned int len)
{
static unsigned long crc_table[256];
static crc32_t crc_table[256];
if (!crc_table[1])
{
unsigned long c;
crc32_t c;
int n, k;
for (n = 0; n < 256; n++)
{
c = (unsigned long)n;
c = (crc32_t)n;
for (k = 0; k < 8; k++) c = (c >> 1) ^ (c & 1 ? 0xedb88320L : 0);
crc_table[n] = c;
}