Skip to content

Commit

Permalink
Merge branch 'ps/reftable-block-search-fix'
Browse files Browse the repository at this point in the history
The reftable code has its own custom binary search function whose
comparison callback has an unusual interface, which caused the
binary search to degenerate into a linear search, which has been
corrected.

* ps/reftable-block-search-fix:
  reftable/block: fix binary search over restart counter
  reftable/record: fix memory leak when decoding object records
  • Loading branch information
gitster committed Mar 21, 2024
2 parents 330ed38 + fffd981 commit 3eba921
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion reftable/block.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ static int restart_key_less(size_t idx, void *args)

result = strbuf_cmp(&a->key, &rkey);
strbuf_release(&rkey);
return result;
return result < 0;
}

void block_iter_copy_from(struct block_iter *dest, struct block_iter *src)
Expand Down
2 changes: 2 additions & 0 deletions reftable/record.c
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,8 @@ static int reftable_obj_record_decode(void *rec, struct strbuf key,
uint64_t last;
int j;

reftable_obj_record_release(r);

REFTABLE_ALLOC_ARRAY(r->hash_prefix, key.len);
memcpy(r->hash_prefix, key.buf, key.len);
r->hash_prefix_len = key.len;
Expand Down

0 comments on commit 3eba921

Please sign in to comment.