CK_HS_FAS(3)
π CK_HS_FAS(3) π
okay bestie, so this is a page from the Concurrency Kit manual (that's libck, and you link it with -lck β noted, remembered, slaying). It's all about one lil function that does a fetch-and-store on a hash set. Iconic behavior. Let's get into it β¨
πΈ LIBRARY πΈ
Concurrency Kit (libck, link it with -lck) π«Ά
β¨ SYNOPSIS β¨
#include <ck_hs.h>
bool
ck_hs_fas(ck_hs_t *hs, unsigned long hash, const void *key,
void **previous);
π¦ DESCRIPTION π¦
So the ck_hs_fas(3) function does a lil fetch and store, no cap. It takes the key you point at with the key argument and stores it into the hash set that hs points to. π
Now, the key in key is expected to already have the hash value you pass in as hash β and bestie, that hash has to have been generated beforehand using the CK_HS_HASH(3) macro. Don't be out here making up hashes, the hash set will know. π
If the call to ck_hs_fas(3) goes well, then congrats, the key in key is now successfully stored in the hash set pointed to by hs β¨ BUT β important β the key must already exist in the hash set. This is a replace, not an insert, iykyk. The existing entry gets replaced by key, and the previous value gets stored into the void pointer that previous points to. π
If the key does not exist in the hash set, then the function returns false and the hash set is left unchanged β nothing happens, no drama, we move on. π
And the part that's genuinely kind of a slay: this function is guaranteed to be stable with respect to memory usage. It's not out here allocating chaos behind your back. π
β RETURN VALUES β
- On a successful completion,
ck_hs_fas(3)returnstrueπ - Otherwise it returns
falseon failure π
π ERRORS π
Behavior is undefined ifkeyorhsare uninitialized. Not "kinda weird", not "probably fine" β UNDEFINED. Init your stuff first, bestie, I am begging. π
π SEE ALSO π
go read these next, they're the whole friend group:
ck_hs_init(3)ck_hs_move(3)ck_hs_destroy(3)CK_HS_HASH(3)ck_hs_iterator_init(3)ck_hs_next(3)ck_hs_get(3)ck_hs_put(3)ck_hs_put_unique(3)ck_hs_remove(3)ck_hs_grow(3)ck_hs_rebuild(3)ck_hs_gc(3)ck_hs_count(3)ck_hs_reset(3)ck_hs_reset_size(3)ck_hs_stat(3)
There's more lore available at http://concurrencykit.org/ if you wanna go deeper π
and that's the whole page, mwah π this one's from the Concurrency Kit fam (that's libck, version dated June 20, 2013), and yes the manual page itself is called CK_HS_FAS(3). go forth and hash responsibly π«Άβ¨
π¦ where this page comes from
- alpine 3.24: ck-doc 0.7.2-r1 Β· BSD-2-Clause AND Apache-2.0
- debian bookworm: libck-dev 0.7.1-10 Β· BSD-2-Clause
- debian trixie: libck-dev 0.7.2-6 Β· BSD-2-Clause
- epel 10: ck-devel 0.7.2-1.el10_1 Β· BSD-2-clause AND Apache-2.0 AND BSD-3-clause
- epel 9: ck-devel 0.7.0-10.el9 Β· BSD
- fedora 43: ck-devel 0.7.2-2.fc43 Β· BSD-2-clause AND Apache-2.0 AND BSD-3-clause
- fedora 43: ck-devel 0.7.2-2.fc43 Β· BSD-2-clause AND Apache-2.0 AND BSD-3-clause
- fedora 44: ck-devel 0.7.2-4.fc44 Β· BSD-2-clause AND Apache-2.0 AND BSD-3-clause
- fedora 44: ck-devel 0.7.2-4.fc44 Β· BSD-2-clause AND Apache-2.0 AND BSD-3-clause
- nixos 26.05: ck 0.7.2
- nixpkgs unstable: ck 0.7.2
- opensuse-leap 16.0: ck-devel 0.7.2-bp160.1.9 Β· Apache-2.0 AND BSD-2-Clause
- opensuse-leap 16.0: ck-devel 0.7.2-bp160.1.9 Β· Apache-2.0 AND BSD-2-Clause
- opensuse-leap 16.0: ck-devel 0.7.2-bp160.1.9 Β· Apache-2.0 AND BSD-2-Clause
- ubuntu jammy: libck-dev 0.7.1-6ubuntu2 Β· BSD-2-Clause
- ubuntu noble: libck-dev 0.7.1-13build1 Β· BSD-2-Clause
- ubuntu questing: libck-dev 0.7.2-5ubuntu1
- ubuntu resolute: libck-dev 0.7.2-5ubuntu2 Β· BSD-2-Clause
- ubuntu stonking: libck-dev 0.7.2-11 Β· BSD-2-Clause
- Copyright 2013 Samy Al Bahra
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms