25#define RABINKARP_MULT2 0xa5b71959U
30#define PAR2X1(hash,buf,i) (RABINKARP_MULT2*(hash) + \
31 RABINKARP_MULT*buf[i] + \
33#define PAR2X2(hash,buf,i) PAR2X1(PAR2X1(hash,buf,i),buf,i+2)
34#define PAR2X4(hash,buf,i) PAR2X2(PAR2X2(hash,buf,i),buf,i+4)
35#define PAR2X8(hash,buf) PAR2X4(PAR2X4(hash,buf,0),buf,8)
38const static uint32_t RABINKARP_MULT_POW2[32] = {
74static inline uint32_t rabinkarp_pow(uint32_t n)
76 const uint32_t *m = RABINKARP_MULT_POW2;
88void rabinkarp_update(
rabinkarp_t *sum,
const unsigned char *buf,
size_t len)
91 uint32_t hash = sum->
hash;
94 hash = PAR2X8(hash, buf);
104 sum->
mult *= rabinkarp_pow((uint32_t)len);
The rabinkarp class implementation of the RabinKarp rollsum.
#define RABINKARP_MULT
The RabinKarp multiplier.
The rabinkarp_t state type.
uint32_t mult
The value of RABINKARP_MULT^count.
size_t count
Count of bytes included in sum.
uint32_t hash
The accumulated hash value.