summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2020-05-05 10:09:28 +0200
committerantirez <antirez@gmail.com>2020-05-05 10:09:28 +0200
commit1063f1d833754cd35e0180e129a0ae61028677d8 (patch)
tree2bb099022ca76cc1fb21d05767619ad747110fc5
parent70a80ef3ad5f46ed79e1336fed7b81f92edce6fb (diff)
downloadredis-1063f1d833754cd35e0180e129a0ae61028677d8.tar.gz
Fix CRC64 initialization outside the Redis server itself.
-rw-r--r--src/crc64.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/crc64.c b/src/crc64.c
index 4cbc019f6..9c555e98b 100644
--- a/src/crc64.c
+++ b/src/crc64.c
@@ -29,6 +29,7 @@
#include "crc64.h"
#include "crcspeed.h"
static uint64_t crc64_table[8][256] = {{0}};
+static int crc64_table_initialized = 0;
#define POLY UINT64_C(0xad93d23594c935a9)
/******************** BEGIN GENERATED PYCRC FUNCTIONS ********************/
@@ -115,10 +116,12 @@ uint64_t _crc64(uint_fast64_t crc, const void *in_data, const uint64_t len) {
/* Initializes the 16KB lookup tables. */
void crc64_init(void) {
crcspeed64native_init(_crc64, crc64_table);
+ crc64_table_initialized = 1;
}
/* Compute crc64 */
uint64_t crc64(uint64_t crc, const unsigned char *s, uint64_t l) {
+ if (!crc64_table_initialized) crc64_init();
return crcspeed64native(crc64_table, crc, (void *) s, l);
}