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 \0 counting, she's not about that life)
  • Param context β€” the custom hash function context that got set through hashkit_set_custom_function() or hashkit_set_custom_distribution_function()
  • Returns β€” your custom hash function should hand back a hash value for key as 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 β€” invalid hashkit_hash_algorithm_t passed.
  • 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 is one_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 custom hashkit_hash_fn function set through hashkit_set_custom_function() or hashkit_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 initialized hashkit_st struct
  • hash_algorithm -- valid hashkit_hash_algorithm_t constant

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 initialized hashkit_st struct
  • function -- hashkit_hash_fn function pointer to use as hash function for HASHKIT_HASH_CUSTOM
  • context -- 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 initialized hashkit_st struct

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 initialized hashkit_st struct
  • hash_algorithm -- valid hashkit_hash_algrothm_t constant

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 initialized hashkit_st struct
  • function -- hashkit_hash_fn function pointer to use as distribution hash function for HASHKIT_HASH_CUSTOM
  • context -- 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 initialized hashkit_st struct

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