THIS IS A TEST INSTANCE ONLY! REPOSITORIES CAN BE DELETED AT ANY TIME!

Git Source Code Mirror - This is a publish-only repository and all pull requests are ignored. Please follow Documentation/SubmittingPatches procedure for any of your improvements.
git
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
1.3KB

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