Merge branch 'nd/style-opening-brace'
[git.git] / sha1-lookup.h
blob7678b23b36c291c7b1b6656e0c42fc14ea12da15
1 #ifndef SHA1_LOOKUP_H
2 #define SHA1_LOOKUP_H
4 typedef const unsigned char *sha1_access_fn(size_t index, void *table);
6 extern int sha1_pos(const unsigned char *sha1,
7 void *table,
8 size_t nr,
9 sha1_access_fn fn);
12 * Searches for sha1 in table, using the given fanout table to determine the
13 * interval to search, then using binary search. Returns 1 if found, 0 if not.
15 * Takes the following parameters:
17 * - sha1: the hash to search for
18 * - fanout_nbo: a 256-element array of NETWORK-order 32-bit integers; the
19 * integer at position i represents the number of elements in table whose
20 * first byte is less than or equal to i
21 * - table: a sorted list of hashes with optional extra information in between
22 * - stride: distance between two consecutive elements in table (should be
23 * GIT_MAX_RAWSZ or greater)
24 * - result: if not NULL, this function stores the element index of the
25 * position found (if the search is successful) or the index of the least
26 * element that is greater than sha1 (if the search is not successful)
28 * This function does not verify the validity of the fanout table.
30 int bsearch_hash(const unsigned char *sha1, const uint32_t *fanout_nbo,
31 const unsigned char *table, size_t stride, uint32_t *result);
32 #endif