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 of
  • key_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 through hashkit_set_custom_function() or hashkit_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 β€” Invalid hashkit_hash_algorithm_t passed.
  • 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_MD5
  • HASHKIT_HASH_CRC
  • HASHKIT_HASH_FNV1_64
  • HASHKIT_HASH_FNV1A_64
  • HASHKIT_HASH_FNV1_32
  • HASHKIT_HASH_FNV1A_32
  • HASHKIT_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_JENKINS
  • HASHKIT_HASH_CUSTOM β€” Use custom hashkit_hash_fn function set through hashkit_set_custom_function() or hashkit_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 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


πŸ’œ 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