nostrdb

an unfairly fast embedded nostr database backed by lmdb
git clone git://jb55.com/nostrdb
Log | Files | Refs | Submodules | README | LICENSE

commit 5fa9f308867b12d49894c5af7bd49689b8835203
parent 0586c51060462ec691ddba4dfafd2745fa8e8ff0
Author: William Casarin <jb55@jb55.com>
Date:   Mon,  3 Nov 2025 10:17:49 -0800

metadata: builder resized function

needed for rust vec reallocs

Signed-off-by: William Casarin <jb55@jb55.com>

Diffstat:
Msrc/metadata.c | 7++++++-
Msrc/nostrdb.h | 1+
2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/metadata.c b/src/metadata.c @@ -124,9 +124,14 @@ struct ndb_note_meta_entry *ndb_note_meta_add_entry(struct ndb_note_meta_builder return entry; } -int ndb_note_meta_builder_init(struct ndb_note_meta_builder *builder, unsigned char *buf, size_t bufsize) +void ndb_note_meta_builder_resized(struct ndb_note_meta_builder *builder, unsigned char *buf, size_t bufsize) { make_cursor(buf, buf + bufsize, &builder->cursor); +} + +int ndb_note_meta_builder_init(struct ndb_note_meta_builder *builder, unsigned char *buf, size_t bufsize) +{ + ndb_note_meta_builder_resized(builder, buf, bufsize); /* allocate some space for the header */ if (!cursor_malloc(&builder->cursor, sizeof(struct ndb_note_meta))) diff --git a/src/nostrdb.h b/src/nostrdb.h @@ -674,6 +674,7 @@ uint32_t *ndb_note_meta_counts_total_reactions(struct ndb_note_meta_entry *entry uint32_t *ndb_note_meta_reaction_count(struct ndb_note_meta_entry *entry); uint64_t *ndb_note_meta_flags(struct ndb_note_meta *meta); void ndb_note_meta_build(struct ndb_note_meta_builder *builder, struct ndb_note_meta **meta); +void ndb_note_meta_builder_resized(struct ndb_note_meta_builder *builder, unsigned char *buf, size_t bufsize); void ndb_note_meta_counts_set(struct ndb_note_meta_entry *entry, uint32_t total_reactions, uint16_t quotes, uint16_t direct_replies, uint32_t thread_replies, uint16_t reposts); void ndb_note_meta_header_init(struct ndb_note_meta *); void ndb_note_meta_reaction_set(struct ndb_note_meta_entry *entry, uint32_t count, union ndb_reaction_str str);