From 934ea80f854d2c9d140690b6bb677f268b4b43e6 Mon Sep 17 00:00:00 2001 From: William Casarin Date: Thu, 25 Jan 2024 17:52:13 -0800 Subject: [PATCH] nostrdb: blocks: add word count interface Signed-off-by: William Casarin --- nostrdb/src/block.c | 4 ++++ nostrdb/src/nostrdb.h | 1 + 2 files changed, 5 insertions(+) diff --git a/nostrdb/src/block.c b/nostrdb/src/block.c index e30c6893..65f25e3e 100644 --- a/nostrdb/src/block.c +++ b/nostrdb/src/block.c @@ -198,3 +198,7 @@ void ndb_blocks_free(struct ndb_blocks *blocks) { int ndb_blocks_flags(struct ndb_blocks *blocks) { return blocks->flags; } + +int ndb_blocks_word_count(struct ndb_blocks *blocks) { + return blocks->words; +} diff --git a/nostrdb/src/nostrdb.h b/nostrdb/src/nostrdb.h index 7a46fb1f..d13fecdd 100644 --- a/nostrdb/src/nostrdb.h +++ b/nostrdb/src/nostrdb.h @@ -536,6 +536,7 @@ int ndb_parse_content(unsigned char *buf, int buf_size, enum ndb_block_type ndb_get_block_type(struct ndb_block *block); int ndb_blocks_flags(struct ndb_blocks *block); size_t ndb_blocks_total_size(struct ndb_blocks *blocks); +int ndb_blocks_word_count(struct ndb_blocks *blocks); /// Free blocks if they are owned, safe to call on unowned blocks as well. void ndb_blocks_free(struct ndb_blocks *blocks);