HASHKIT_FUNCTION(3)
π HASHKIT_FUNCTION π
okay so this is HASHKIT_FUNCTION(3), straight outta libmemcached-awesome, and bestie it's giving "libhashkit's greatest hits". we're talking hash functions, distribution functions, custom callbacks, the whole vibe. grab a boba, we're doing this π§β¨
β¨ NAME β¨
hashkit_function β libhashkit Documentation. that's it, that's the name, short and iconic π
πΈ SYNOPSIS πΈ
#include <libhashkit-1.0/hashkit.h>
Compile and link with -lhashkit.
π¦ the custom hash function typedef
typedef uint32_t (*hashkit_hash_fn)(const char *key, size_t key_length,
void *context)
Param key β the key you wanna generate a hash of. the raw material, the moment, the it-girl π
Param key_length β the length of the key, and no, it does not count any terminating zero byte. don't include the null, she's not invited π
Param context β the custom hash function context that got set through hashkit_set_custom_function() or hashkit_set_custom_distribution_function(). it's your lil suitcase of extra info π
Returns β your custom hash function should hand back a hash value for key as an unsigned 32bit integer. no cap, that's the contract π₯
π the return type
typedef enum hashkit_return_t hashkit_return_t
enum hashkit_return_t
- enumerator
HASHKIT_SUCCESSβ operation succeeded. slay π - enumerator
HASHKIT_FAILUREβ operation failed. it's giving flop π - enumerator
HASHKIT_MEMORY_ALLOCATION_FAILUREβ memory allocation failed. the malloc said no π - enumerator
HASHKIT_INVALID_HASHβ an invalidhashkit_hash_algorithm_tgot passed. wrong algorithm bestie π - enumerator
HASHKIT_INVALID_ARGUMENTβ an invalid argument got passed. ma'am that's not a valid argument π«
π the hash algorithm type
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, the moment β - 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 has been built with HSIEH support. so if she's not compiled in, she's simply not there, no hard feelings β¨ - enumerator
HASHKIT_HASH_MURMURβ only available if libhashkit has been built with MURMUR support. same deal π - enumerator
HASHKIT_HASH_MURMUR3β only available if libhashkit has been built with MURMUR support. yes, again, build flags decide everything π« - enumerator
HASHKIT_HASH_JENKINS - enumerator
HASHKIT_HASH_CUSTOMβ use the customhashkit_hash_fnfunction that got set throughhashkit_set_custom_function()orhashkit_set_custom_distribution_function(). this one's your girl, you wrote her π
π the functions
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
π«Ά DESCRIPTION π«Ά
so like, these functions are the ones you use to set and retrieve the key and distribution hash functions. that's the whole job. set them, get them, live your truth π¦β¨
π RETURN VALUE π
hashkit_set_function(), hashkit_set_custom_function() and the distribution equivalents all return hashkit_return_t::HASHKIT_SUCCESS on success. green flags only bestie π
hashkit_get_function() and hashkit_get_distribution_function() return hashkit_hash_algorithm_t, indicating the hash function that's in use. they're just telling you who's currently holding the aux π§
π₯ SEE ALSO π₯
and that's the whole page, bestie, you ate π
β¨ this was HASHKIT_FUNCTION(3) from libmemcached-awesome, version 1.1, dated Jul 24, 2025 β go forth and hash responsibly, ily, mwah πππ¦
π¦ 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