/* Copyright (c) 2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "bloomfilter.h"
#include "murmurhash3.h"
#include "md5.h"
#include "randgen.h"
#include <math.h>
struct bloomfilter {
int refcount;
unsigned int nk;
bloomfilter_hash_func_t *const *k;
};
/* use only murmurhash3 by default */
};
static inline size_t
{
#ifdef _LP64
/* rolls 128 bit result into a 64 bit result by xoring the first 64 bits
and seed, and remaining 64 bits. */
return be64_to_cpu_unaligned(&result[0]) ^
#else
/* rolls 128 bit result into a 32 bit result by folding
all the successive 32 bit values into one together with seed. */
return be32_to_cpu_unaligned(&result[0]) ^
seed;
#endif
}
{
/* murmur includes seed already */
return bloomfilter_hash_fold(result, 0);
}
{
}
struct bloomfilter *
bloomfilter_hash_func_t *const *hash_functions)
{
/* allocate extra byte to round up result */
bf->k = hash_functions;
while(*hash_functions != NULL) {
}
return bf;
}
{
}
{
return;
return;
/* in case system pool was used .. */
}
{
return bf->total_added;
}
{
bloomfilter_hash_func_t *const *k = bf->k;
for(;*k != NULL; k++) {
return FALSE;
}
return TRUE;
}
{
bloomfilter_hash_func_t *const *k = bf->k;
/* total added will cap at size_t, because it's an estimate */
bf->total_added++;
for(;*k != NULL; k++) {
}
}