nostrdb: filter: fix ndb_filter_init_with and make public
This fixes an allocation issue with ndb_filter_init_with for small
page sizes. instead of allocating the buffer around pages, we allocate
based on total buffer size.
Fixes: f7aac3215575 ("filter: introduce ndb_filter_init_with")
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
committed by
Daniel D’Aquino
parent
ec798bdeb2
commit
d3496af5cc
@@ -503,6 +503,12 @@ int ndb_builder_push_tag_str(struct ndb_builder *builder, const char *str, int l
|
||||
|
||||
// FILTERS
|
||||
int ndb_filter_init(struct ndb_filter *);
|
||||
|
||||
/// Allocate a filter with a fixed sized buffer (where pages is number of 4096-byte sized blocks)
|
||||
/// You can set pages to 1 if you know you are constructing small filters
|
||||
// TODO: replace this with passed-in buffers
|
||||
int ndb_filter_init_with(struct ndb_filter *filter, int pages);
|
||||
|
||||
int ndb_filter_add_id_element(struct ndb_filter *, const unsigned char *id);
|
||||
int ndb_filter_add_int_element(struct ndb_filter *, uint64_t integer);
|
||||
int ndb_filter_add_str_element(struct ndb_filter *, const char *str);
|
||||
|
||||
Reference in New Issue
Block a user