Skip to content

Commit

Permalink
crc64.c modified for incremental computation.
Browse files Browse the repository at this point in the history
  • Loading branch information
antirez committed Apr 10, 2012
1 parent 9ba4d5a commit bb99f42
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/crc64.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand All @@ -186,7 +185,7 @@ uint64_t crc64(const unsigned char *s, uint64_t l) {
#include <stdio.h>
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
2 changes: 1 addition & 1 deletion src/redis.h
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,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 */
Expand Down

0 comments on commit bb99f42

Please sign in to comment.