Skip to content

Commit

Permalink
Merge remote-tracking branch 'github/pr/43'
Browse files Browse the repository at this point in the history
Pull some fixes from rusty related to ndb_builder_find_str. It seems to
be matching prefixes instead of entire strings.

Rusty Russell (3):
      Makefile: fix header dependencies.
      content_parser: fix incorrect comment.
      nostrdb: fix ndb_builder_find_str.
  • Loading branch information
jb55 committed Aug 27, 2024
2 parents 9936d15 + 413fca1 commit da79a2b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ CHECKDATA=testdata/db/v0/data.mdb

all: $(BIN) lib bench

%.o: %.c $(HEADERS)
$(OBJS): $(HEADERS)

%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<

libnostrdb.a: $(OBJS)
Expand Down
2 changes: 1 addition & 1 deletion src/content_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ static int parse_hashtag(struct cursor *cur, struct ndb_block *block) {
//
// bech32 blocks are stored as:
//
// nostr_bech32_type : varint
// bech32_buffer_size : u16
// nostr_bech32_type : varint
// bech32_data : [u8]
//
// The TLV form is compact already, so we just use it directly
Expand Down
2 changes: 1 addition & 1 deletion src/nostrdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -5071,7 +5071,7 @@ static inline int ndb_builder_find_str(struct ndb_builder *builder,
uint32_t index = ((uint32_t*)builder->str_indices.start)[i];
const char *some_str = (const char*)builder->strings.start + index;

if (!memcmp(some_str, str, len)) {
if (!memcmp(some_str, str, len) && some_str[len] == '\0') {
// found an existing matching str, use that index
*pstr = ndb_offset_str(index);
return 1;
Expand Down

0 comments on commit da79a2b

Please sign in to comment.