aboutsummaryrefslogtreecommitdiffstats
path: root/reftable/basics.h
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2024-04-12 11:31:39 -0700
committerJunio C Hamano <gitster@pobox.com>2024-04-12 11:31:39 -0700
commit7fbe3ead1989bed1ea1fc8754d13aa7af16dd946 (patch)
treeef381d996e8cb285936a5245b50e5ee08c2227dd /reftable/basics.h
parent847af43a3afb39394d5fe58192f94b993ca18f9f (diff)
parentd51d8cc36831bdabbbcec8553a7e83d9f5a3be4d (diff)
downloadgit-7fbe3ead1989bed1ea1fc8754d13aa7af16dd946.tar.gz
Merge branch 'ps/reftable-binsearch-updates'
Reftable code clean-up and some bugfixes. * ps/reftable-binsearch-updates: reftable/block: avoid decoding keys when searching restart points reftable/record: extract function to decode key lengths reftable/block: fix error handling when searching restart points reftable/block: refactor binary search over restart points reftable/refname: refactor binary search over refnames reftable/basics: improve `binsearch()` test reftable/basics: fix return type of `binsearch()` to be `size_t`
Diffstat (limited to 'reftable/basics.h')
-rw-r--r--reftable/basics.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/reftable/basics.h b/reftable/basics.h
index 91f3533efe..523ecd5307 100644
--- a/reftable/basics.h
+++ b/reftable/basics.h
@@ -22,13 +22,14 @@ uint32_t get_be24(uint8_t *in);
void put_be16(uint8_t *out, uint16_t i);
/*
- * find smallest index i in [0, sz) at which f(i) is true, assuming
- * that f is ascending. Return sz if f(i) is false for all indices.
+ * find smallest index i in [0, sz) at which `f(i) > 0`, assuming that f is
+ * ascending. Return sz if `f(i) == 0` for all indices. The search is aborted
+ * and `sz` is returned in case `f(i) < 0`.
*
* Contrary to bsearch(3), this returns something useful if the argument is not
* found.
*/
-int binsearch(size_t sz, int (*f)(size_t k, void *args), void *args);
+size_t binsearch(size_t sz, int (*f)(size_t k, void *args), void *args);
/*
* Frees a NULL terminated array of malloced strings. The array itself is also