libcritnib(3)
π libcritnib β an ordered map data structure with lock-free reads π
okay bestie, sit DOWN, because this is the critnib manual page and she is lowkey iconic. it's libcritnib, a library for an ordered map data structure, and the whole vibe is that reads are lock-free β readers don't gotta wait on anybody. periodt. π¦
β¨ NAME β¨
libcritnib β an ordered map data structure with lock-free reads. that's the whole name, that's the whole assignment, and she ate. π
πΈ SYNOPSIS πΈ
#include <critnib.h>
and then, like, link her in:
-lcritnib
no cap, that's it. link with -lcritnib and you're in. π«Ά
π DESCRIPTION π
π Functions:
okay so here's the whole friend group, one by one, no skips, no cuts. π
critnib *critnib_new(void);β makes you a brand new, empty critnib structure. fresh out the box, zero keys, main character energy. β¨void critnib_delete(critnib *c);β destroys her and frees the memory. and listen, important detail: items you removed earlier get reused, but their memory does not get freed until you call this function. so like, the removals were never really gone gone, they were just in the group chat but muted. call this and it's actually over. πint critnib_insert(critnib *c, uintptr_t key, void *value, int update);β adds akey:valuepair to the critnib structure. here's the tea onupdate: if it's non-zero, a key that already exists gets its value updated (glow up β¨). if it's zero, the function returnsEEXISTinstead. it may also returnENOMEMif we're out of memory, or0if everything went okay. slay.void *critnib_remove(critnib *c, uintptr_t key);β yeets a given key out of the structure. you get its associated value back as a parting gift, or0(NULL) if there was no such key. sorry bestie, no key, no souvenir. πvoid *critnib_get(critnib *c, uintptr_t key);β grabs you a value for a given key, or0(NULL) if it's not present. simple, clean, no drama.void *critnib_find_le(critnib *c, uintptr_t key);β searches for the largest key not exceeding the argument and hands you its value. like finding the closest thing that didn't overstep. π§int critnib_find(critnib *c, uintptr_t key, enum find_dir_t dir, uintptr_t *rkey, void **rvalue);β searches for a key that's smaller (FIND_L), smaller-or-equal (FIND_LE), equal (FIND_EQ), greater-or-equal (FIND_GE), or greater (FIND_G) than the argument. if found, the key and value get assigned to*rkeyand*rvalue(and yes, those may be null if you wanna skip the assignment, we respect boundaries), and1is returned. πvoid critnib_iter(critnib *c, uintptr_t min, uintptr_t max, func, void *privdata);β walks the structure, visiting all entries whose keys are at leastminbut no larger thanmax(give-1for no max, live a little). she callsfuncfor every entry she finds. and iffuncreturns a non-zero value, the walk is aborted β that's the emergency exit, bestie. πͺ
the prototype for func should be:
int (*func)(uintptr_t key, void *value, void *privdata);
where privdata is an optional value passed to the iterator.
β οΈ NB. this version of the library implements the iterator in a crude blocking way, stalling any concurrent writers and iterators. it's giving "held the door open for way too long." π this limitation will be lifted in the future, so like, patience is a virtue or whatever. π°οΈ
that's the whole page, bestie β go forth and map your keys in order, lock-free, no cap. ππ
πΈ this page came to you from the libcritnib manual, rendered by perl v5.38.2, dated 2024-04-22. mwah, kissing you goodbye. ππ
π¦ where this page comes from
- ubuntu noble: libcritnib-dev 1.1-2build1 Β· BSD-3-Clause
- ubuntu questing: libcritnib-dev 1.1-2build1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms