CK_HT_HASH_DIRECT(3)

✨ ck_ht_hash_direct ✨ β€” the manual page, section 3, bestie edition πŸ’…

okay so you found yourself staring at ck_ht_hash_direct(3) and you're like "what is this, why is this, who is she" β€” don't worry, I got you. Sit down, hydrate, let's go 🫢


🌸 NAME 🌸

ck_ht_hash_direct β€” generate a hash value for a hash table πŸ’–


πŸ“š LIBRARY πŸ“š

Concurrency Kit, aka libck, which you link with -lck. Iconic library, no notes πŸ‘‘


πŸŽ€ SYNOPSIS πŸŽ€

#include <ck_ht.h>

void
ck_ht_hash_direct(ck_ht_hash_t *h, ck_ht_t *ht, uintptr_t key);

look at her. three args, zero drama, void return. main character energy fr fr ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

So here's the tea β˜• β€” ck_ht_hash_direct() generates a hash value and stashes it in the object that h points to. That hash value is valid for use in the hash table that ht points to, for the key you passed in. And key here is of direct type, meaning it's the key itself, not a pointer to it. It's giving "no middleman, we go direct" πŸ’…

That's it. That's the whole function. Lowkey elegant, highkey essential.


πŸ’œ RETURN VALUES πŸ’œ

ck_ht_hash_direct() has no return value. Nothing. Nada. She's a void girlie β€” the result goes into h and that's where you go get it 🌈


πŸ’€ ERRORS πŸ’€

okay bestie, this is the part where we get serious for a sec 🚨

Behavior is undefined if key is a 0 or UINTPTR_MAX value, or if ht is uninitialized.

UNDEFINED. Not "an error code", not "a warning", not "she'll be a little grumpy" β€” undefined behavior. Do not pass 0, do not pass UINTPTR_MAX, do not roll up with an uninitialized ht. It's not the vibe. It will never be the vibe. πŸ™ˆ


πŸ‘‘ SEE ALSO πŸ‘‘

the whole friend group, in alphabetical-ish order, all of them serving:

and if you want even more lore, additional information is available at http://concurrencykit.org/ πŸ¦‹


and that's the page!! this one was dated March 29, 2012 and lives as CK_HT_HASH_DIRECT(3) β€” yeah she's been iconic since 2012 and she's still serving πŸ’– mwah, go forth and hash responsibly βœ¨πŸŽ€

πŸ“¦ where this page comes from