HASHKIT_GET_FUNCTION(3)
π NAME π
okay so this is hashkit_get_function from the libhashkit Documentation (and yeah, the whole page you're reading lives in the libmemcached-awesome manual, section 3, bestie π
).
β¨ SYNOPSIS β¨
#include <libhashkit-1.0/hashkit.h>
Compile and link with -lhashkit
yes queen, that's the header and the linker flag, no notes π
π¦ the function pointer type, aka the whole personality
typedef uint32_t (*hashkit_hash_fn)(const char *key, size_t key_length,
void *context)
here's what each lil param means:
keyβ the key to generate a hash ofkey_lengthβ the length of the key without any terminating zero byte (so don't you dare count the\0, babe π)contextβ the custom hash function context set throughhashkit_set_custom_function()orhashkit_set_custom_distribution_function()
Returns β the custom hash function should return a hash value for key as an unsigned 32bit integer β¨
πΈ the return type
typedef enum hashkit_return_t hashkit_return_t
enum hashkit_return_t
and the enumerators, one by one, no skips:
HASHKIT_SUCCESSβ Operation succeeded. slay πHASHKIT_FAILUREβ Operation failed. not slay πHASHKIT_MEMORY_ALLOCATION_FAILUREβ Memory allocation failed. the malloc said no πHASHKIT_INVALID_HASHβ Invalidhashkit_hash_algorithm_tpassed.HASHKIT_INVALID_ARGUMENTβ Invalid argument passed.
π the algorithm type, the menu of vibes
typedef enum hashkit_hash_algorithm_t hashkit_hash_algorithm_t
enum hashkit_hash_algorithm_t
HASHKIT_HASH_DEFAULTβ Default hash algorithm (one_at_a_time). the main character π«ΆHASHKIT_HASH_MD5HASHKIT_HASH_CRCHASHKIT_HASH_FNV1_64HASHKIT_HASH_FNV1A_64HASHKIT_HASH_FNV1_32HASHKIT_HASH_FNV1A_32HASHKIT_HASH_HSIEHβ Only available if libhashkit hash been built with HSIEH support.HASHKIT_HASH_MURMURβ Only available if libhashkit has been built with MURMUR support.HASHKIT_HASH_MURMUR3β Only available if libhashkit has been built with MURMUR support.HASHKIT_HASH_JENKINSHASHKIT_HASH_CUSTOMβ Use customhashkit_hash_fnfunction set throughhashkit_set_custom_function()orhashkit_set_custom_distribution_function(). build-a-bear but it's a hash function π§
π the actual 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 π
okay so the whole point of these functions: they're used to set and retrieve the key and distribution hash functions. that's it, that's the tea β set one, get one, set the distribution one, get the distribution one. obsessed.
β RETURN VALUE β
hashkit_set_function(), hashkit_set_custom_function() and the distribution equivalents return hashkit_return_t::HASHKIT_SUCCESS on success. π
hashkit_get_function() and hashkit_get_distribution_function() return hashkit_hash_algorithm_t indicating the hash function used. π
π₯ SEE ALSO π₯
and that's the whole page, bestie!! this one came out of libmemcached-awesome, version 1.1, dated Jul 24, 2025 β go forth and hash responsibly, ily πβ¨π¦
π¦ 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