From 0a301e93062df3735f9bb87c445e18d98a4b6efb Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Fri, 23 Sep 2016 11:57:00 -0600 Subject: [PATCH] bloom: add string version Signed-off-by: Jens Axboe --- lib/bloom.c | 7 ++++++- lib/bloom.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/bloom.c b/lib/bloom.c index 3369c5e9..c2e6c11f 100644 --- a/lib/bloom.c +++ b/lib/bloom.c @@ -88,7 +88,7 @@ void bloom_free(struct bloom *b) free(b); } -static bool __bloom_check(struct bloom *b, void *data, unsigned int len, +static bool __bloom_check(struct bloom *b, const void *data, unsigned int len, bool set) { uint32_t hash[N_HASHES]; @@ -117,3 +117,8 @@ bool bloom_set(struct bloom *b, uint32_t *data, unsigned int nwords) { return __bloom_check(b, data, nwords * sizeof(uint32_t), true); } + +bool bloom_set_string(struct bloom *b, const char *data, unsigned int len) +{ + return __bloom_check(b, data, len, true); +} diff --git a/lib/bloom.h b/lib/bloom.h index 329fd36a..d40d9f6b 100644 --- a/lib/bloom.h +++ b/lib/bloom.h @@ -9,5 +9,6 @@ struct bloom; struct bloom *bloom_new(uint64_t entries); void bloom_free(struct bloom *b); bool bloom_set(struct bloom *b, uint32_t *data, unsigned int nwords); +bool bloom_set_string(struct bloom *b, const char *data, unsigned int len); #endif -- 2.25.1