bloom: add string version
authorJens Axboe <axboe@fb.com>
Fri, 23 Sep 2016 17:57:00 +0000 (11:57 -0600)
committerJens Axboe <axboe@fb.com>
Fri, 23 Sep 2016 17:57:00 +0000 (11:57 -0600)
Signed-off-by: Jens Axboe <axboe@fb.com>
lib/bloom.c
lib/bloom.h

index 3369c5e99ed72bb112fcb95b440fcc27919f93c4..c2e6c11f2e1444020ae18225f8277938827c37f9 100644 (file)
@@ -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);
+}
index 329fd36ab77b21f4a75e0af31e92ea85294b0992..d40d9f6bacf3ad15bbbcd65fe4b8491d1ebdb1f7 100644 (file)
@@ -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