CK_RHS_SET(3)

✨ ck_rhs_set β€” bestie, we're putting a key INTO the hash set ✨

okay so real talk, this one lives in the Concurrency Kit (that's libck, and you link it with -lck) πŸ’– she's a little function with big main character energy and she's about to file your key away in a hash set. let's get into it.


🌸 SYNOPSIS 🌸

#include <ck_rhs.h>

bool
ck_rhs_set(ck_rhs_t *hs, unsigned long hash, const void *key,
    void **previous);

like. look at her. four args. no cap. 🫢


πŸ’… DESCRIPTION πŸ’…

so ck_rhs_set(3) takes the key you point at with the key argument and stores it in the hash set that hs points to. the key in key is expected to already have the hash value you're passing in as the hash argument β€” and iykyk, that hash was generated earlier using the CK_RHS_HASH(3) macro. don't just make up a hash number, bestie, that's not the vibe. πŸ’€

if the call to ck_rhs_set(3) goes through successfully, then the key in key is officially stored in the hash set pointed to by hs. iconic. ✨

but here's the tea β˜• β€” if that key already exists in the hash set, then it gets replaced by key, and the previous value gets stored into the void pointer that previous points to. so you get your old thing back, cute.

and if previous is set to NULL? then key was not a replacement for an existing entry in the hash set. no prior entry, no drama. 🌈


πŸŽ€ RETURN VALUES πŸŽ€

on a successful completion, ck_rhs_set(3) returns true and honestly? slay. otherwise she returns false on failure. that's it, that's the whole vibe check. πŸ’–


πŸ¦‹ ERRORS πŸ¦‹

⚠️ behavior is undefined if key or hs are uninitialized. not "undefined" like quirky-undefined, undefined like we do not know what happens and it is not our problem. please initialize your stuff, bestie, i am begging πŸ™ˆ

the function will also return false if the hash set could not be enlarged to accomodate the key insertion. like, she tried to grow for you and she couldn't. it happens. 😭


πŸ‘‘ SEE ALSO πŸ‘‘

the whole squad, fr fr:

and if you want even more lore, additional information is available at http://concurrencykit.org/ 🌐✨


mwah πŸ’‹ that's the page. this one's from September 17, 2012 and it's a CK_RHS_SET(3) situation through and through. go forth and set your keys, bestie, you've got this 🫢🌸

πŸ“¦ where this page comes from