diff options
author | Karsten Blees <karsten.blees@gmail.com> | 2014-07-03 02:20:20 +0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-07-08 00:56:24 +0400 |
commit | 039dc71a7cb824300e242f8abc0fcb19dac93641 (patch) | |
tree | 9c38bb8655e0314cfe122b7355922c2413533825 /Documentation/technical | |
parent | 6f92e5ff3cdc813de8ef5327fd4bad492fb7d6c9 (diff) |
hashmap: factor out getting a hash code from a SHA1
Copying the first bytes of a SHA1 is duplicated in six places,
however, the implications (the actual value would depend on the
endianness of the platform) is documented only once.
Add a properly documented API for this.
Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'Documentation/technical')
-rw-r--r-- | Documentation/technical/api-hashmap.txt | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Documentation/technical/api-hashmap.txt b/Documentation/technical/api-hashmap.txt index b977ae8bbb..37727cd2c0 100644 --- a/Documentation/technical/api-hashmap.txt +++ b/Documentation/technical/api-hashmap.txt @@ -58,6 +58,15 @@ Functions + `strihash` and `memihash` are case insensitive versions. +`unsigned int sha1hash(const unsigned char *sha1)`:: + + Converts a cryptographic hash (e.g. SHA-1) into an int-sized hash code + for use in hash tables. Cryptographic hashes are supposed to have + uniform distribution, so in contrast to `memhash()`, this just copies + the first `sizeof(int)` bytes without shuffling any bits. Note that + the results will be different on big-endian and little-endian + platforms, so they should not be stored or transferred over the net. + `void hashmap_init(struct hashmap *map, hashmap_cmp_fn equals_function, size_t initial_size)`:: Initializes a hashmap structure. |