From 88c1d9550d198fd7df426b19ea67e9c51c92a811 Mon Sep 17 00:00:00 2001 From: antirez Date: Mon, 9 Apr 2012 12:20:47 +0200 Subject: [PATCH] crc64.c modified for incremental computation. --- src/crc64.c | 5 ++--- src/redis.h | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/crc64.c b/src/crc64.c index f2ea8d4a..ecdba90e 100644 --- a/src/crc64.c +++ b/src/crc64.c @@ -170,8 +170,7 @@ static const uint64_t crc64_tab[256] = { UINT64_C(0x536fa08fdfd90e51), UINT64_C(0x29b7d047efec8728), }; -uint64_t crc64(const unsigned char *s, uint64_t l) { - uint64_t crc = 0; +uint64_t crc64(uint64_t crc, const unsigned char *s, uint64_t l) { uint64_t j; for (j = 0; j < l; j++) { @@ -186,7 +185,7 @@ uint64_t crc64(const unsigned char *s, uint64_t l) { #include int main(void) { printf("e9c6d914c4b8d9ca == %016llx\n", - (unsigned long long) crc64((unsigned char*)"123456789",9)); + (unsigned long long) crc64(0,(unsigned char*)"123456789",9)); return 0; } #endif diff --git a/src/redis.h b/src/redis.h index ba209c7b..52d39bc7 100644 --- a/src/redis.h +++ b/src/redis.h @@ -827,7 +827,7 @@ extern dictType hashDictType; long long ustime(void); long long mstime(void); void getRandomHexChars(char *p, unsigned int len); -uint64_t crc64(const unsigned char *s, uint64_t l); +uint64_t crc64(uint64_t crc, const unsigned char *s, uint64_t l); void exitFromChild(int retcode); /* networking.c -- Networking and Client related operations */ -- 2.45.2