HASHKIT_GET_DISTRIBUTION_FUNCTION(3)
π NAME π
hashkit_get_distribution_function β the libhashkit documentation, bestie. It's from libmemcached-awesome, and yes she's that girl. π
β¨ SYNOPSIS β¨
#include <libhashkit-1.0/hashkit.h>
Compile and link with -lhashkit β don't forget this part, it's giving "why won't it link" energy otherwise π
typedef uint32_t (*hashkit_hash_fn)(const char *key, size_t key_length,
void *context)
Okay so this is the custom hash function shape, and here's what every piece means:
- Param
keyβ the key we're generating a hash of π - Param
key_lengthβ how long that key is, without any terminating zero byte (no sneaky\0counting, she's not about that life) - Param
contextβ the custom hash function context that got set throughhashkit_set_custom_function()orhashkit_set_custom_distribution_function() - Returns β your custom hash function should hand back a hash value for
keyas an unsigned 32bit integer β¨
typedef enum hashkit_return_t hashkit_return_t
enum hashkit_return_t
- enumerator
HASHKIT_SUCCESSβ operation succeeded. slay. π - enumerator
HASHKIT_FAILUREβ operation failed. π - enumerator
HASHKIT_MEMORY_ALLOCATION_FAILUREβ memory allocation failed. she's out of room, no cap. - enumerator
HASHKIT_INVALID_HASHβ invalidhashkit_hash_algorithm_tpassed. - enumerator
HASHKIT_INVALID_ARGUMENTβ invalid argument passed.
typedef enum hashkit_hash_algorithm_t hashkit_hash_algorithm_t
enum hashkit_hash_algorithm_t
- enumerator
HASHKIT_HASH_DEFAULTβ the default hash algorithm, which isone_at_a_time. the OG, the blueprint. - enumerator
HASHKIT_HASH_MD5 - enumerator
HASHKIT_HASH_CRC - enumerator
HASHKIT_HASH_FNV1_64 - enumerator
HASHKIT_HASH_FNV1A_64 - enumerator
HASHKIT_HASH_FNV1_32 - enumerator
HASHKIT_HASH_FNV1A_32 - enumerator
HASHKIT_HASH_HSIEHβ only available if libhashkit hash been built with HSIEH support. (that typo is in the original, we're keeping it, it's canon now π) - enumerator
HASHKIT_HASH_MURMURβ only available if libhashkit has been built with MURMUR support. - enumerator
HASHKIT_HASH_MURMUR3β only available if libhashkit has been built with MURMUR support. - enumerator
HASHKIT_HASH_JENKINS - enumerator
HASHKIT_HASH_CUSTOMβ use the customhashkit_hash_fnfunction set throughhashkit_set_custom_function()orhashkit_set_custom_distribution_function(). your own lil invention, main character energy fr fr β¨
hashkit_return_t hashkit_set_function(hashkit_st *hash,
hashkit_hash_algorithm_t hash_algorithm)
Parameters
hash-- pointer to an initializedhashkit_ststructhash_algorithm-- validhashkit_hash_algorithm_tconstant
Returns
hashkit_return_t indicating success or failure π«Ά
hashkit_return_t hashkit_set_custom_function(hashkit_st *hash,
hashkit_hash_fn function, void *context)
Parameters
hash-- pointer to initializedhashkit_ststructfunction--hashkit_hash_fnfunction pointer to use as hash function forHASHKIT_HASH_CUSTOMcontext-- pointer to an opaque user managed context for the custom hash function
Returns
hashkit_return_t indicating success or failure π
hashkit_hash_algorithm_t hashkit_get_function(const hashkit_st *hash)
Parameters
hash-- pointer to an initializedhashkit_ststruct
Returns
hashkit_hash_algorithm_t indicating the currently set hash algorithm to use πΈ
hashkit_return_t hashkit_set_distribution_function(hashkit_st *hash,
hashkit_hash_algorithm_t hash_algorithm)
Parameters
hash-- pointer to an initializedhashkit_ststructhash_algorithm-- validhashkit_hash_algrothm_tconstant
Returns
hashkit_return_t indicating success or failure β¨
hashkit_return_t hashkit_set_custom_distribution_function(hashkit_st
*hash, hashkit_hash_fn function, void *context)
Parameters
hash-- pointer to initializedhashkit_ststructfunction--hashkit_hash_fnfunction pointer to use as distribution hash function forHASHKIT_HASH_CUSTOMcontext-- pointer to an opaque user managed context for the custom distribution hash function
hashkit_hash_algorithm_t hashkit_get_distribution_function(const
hashkit_st *hash)
Parameters
hash-- pointer to an initializedhashkit_ststruct
Returns
hashkit_hash_algorithm_t indicating the currently set distribution hash algorithm to use. yes, the distribution one. different function, different vibe. π
π DESCRIPTION π
So these functions are the whole little squad that sets and retrieves the key hash functions and the distribution hash functions. That's it, that's the job. Simple. Iconic. π
π RETURN VALUE π
hashkit_set_function(), hashkit_set_custom_function() and the distribution equivalents all return hashkit_return_t::HASHKIT_SUCCESS when they succeed. π₯³
hashkit_get_function() and hashkit_get_distribution_function() return hashkit_hash_algorithm_t, telling you which hash function is being used. iykyk. β¨
π SEE ALSO π
libhashkit(3) hashkit_create(3) hashkit_functions(3) β go read those too bestie, they're part of the lore π¦
Okay that's the whole page, mwah π this was libmemcached-awesome version 1.1, dated Jul 24, 2025 β thanks for coming to my TED talk, go hash something responsibly, ily, bye!! πβ¨π«Ά
π¦ where this page comes from
- fedora 43: libmemcached-awesome-devel 1.1.4-7.fc43 Β· BSD-3-Clause
- fedora 43: libmemcached-awesome-devel 1.1.4-7.fc43 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms