HASHKIT_CREATE(3)

πŸ¦‹ NAME πŸ¦‹

hashkit_create β€” it's the libhashkit documentation bestie, we're doing the whole hashkit object lifecycle here πŸ’…

Oh also hiii, you're reading the HASHKIT_CREATE(3) page from the libmemcached-awesome manual. Yes queen, section 3, library functions, let's GO.


🌸 SYNOPSIS 🌸

#include <libhashkit-1.0/hashkit.h>
       Compile and link with -lhashkit
typedef struct hashkit_st hashkit_st

✨ hashkit_st *hashkit_create(hashkit_st *hash)

Parameters

  • hash β€” the memory address of a hashkit_st struct. If you pass a nullptr, the struct gets dynamically allocated by libhashkit for you 🫢

Returns

  • pointer to the initialized hashkit_st structure

✨ hashkit_st *hashkit_clone(hashkit_st *destination, const hashkit_st *ptr)

Parameters

  • destination β€” memory address of a hashkit_st struct; if a nullptr is passed, the struct will be dynamically allocated by libhashkit
  • ptr β€” pointer of the hashkit_st struct to copy

Returns

  • pointer to a hashkit_st structure (destination, if it wasn't nullptr), initialized from ptr

✨ void hashkit_free(hashkit_st *hash)

Parameters

  • hash β€” pointer to an initialized hashkit_st struct

✨ bool hashkit_is_allocated(const hashkit_st *hash)

Parameters

  • hash β€” pointer to an initialized hashkit_st struct

Returns

  • bool, whether the hash struct was dynamically allocated

πŸ’œ DESCRIPTION πŸ’œ

Okay so hashkit_create() initializes a hashkit object so it's ready to be used, iconic behavior honestly. Pass a nullptr as the hash argument and the memory for the object gets allocated for you (so generous πŸ’–). Or, if you hand it a pre-allocated piece of memory, that gets initialized for use instead. Either way you're covered.

Then there's hashkit_clone(), which initializes a hashkit object pretty much the same way as hashkit_create(), except β€” plot twist β€” it doesn't use the default settings. It uses the settings of the ptr hashkit object instead. Copying the vibe, not the defaults. ✨

hashkit_free() frees any resources being consumed by hashkit objects that were initialized with hashkit_create() or hashkit_clone(). Clean up after yourself, bestie, no cap 🧹

And hashkit_is_allocated() reports whether the memory was allocated for a hashkit object. Yes, that's the whole thing. It just tells you. πŸŽ€


πŸ‘‘ RETURN VALUE πŸ‘‘

hashkit_create() and hashkit_clone() will return nullptr on failure, or a pointer to hashkit_st on success. Slay when it works, nullptr when it doesn't 😭

hashkit_is_allocated() returns true if the memory for the hashkit object was allocated inside of hashkit_create() or hashkit_clone(). Otherwise it's false, and that means the memory was user-supplied. Periodt.


🌈 SEE ALSO 🌈

libhashkit(3) hashkit_value(3) hashkit_function3)

ngl bestie, that last one is written exactly like that in the original. Not me fixing it. Not my job. It's giving "as-shipped" πŸ’€

That's the whole page! Brought to you by libmemcached-awesome, version 1.1, dated Jul 24, 2025 β€” mwah, take care of your hashkit objects and they'll take care of you πŸ«ΆπŸ’–βœ¨

πŸ“¦ where this page comes from