critbit0_insert(3)
π critbit0_insert β ok bestie, let's talk about putting strings in trees π
So this page is the manual for critbit0_insert(3), and it lives in the Library Functions Manual. Yes, the third section. Very demure, very C library of it. π
β¨ NAME β¨
critbit0_insert β insert a string into a critbit tree π³
πΈ SYNTAX πΈ
Okay so first you gotta pull in the header, like:
#include <libowfat/critbit.h>
Then you declare your tree and zero it out, no cap:
critbit0_tree cb = { 0 };
And here's the function itself, the main character:
int critbit0_insert(critbit0_tree* cb,const char* str);
π¦ DESCRIPTION π¦
critbit0_insert attempts to insert a string into a critbit0 tree. π«Ά
And here's the thing you gotta know, bestie, because the way this works is iconic: it does not just stash a copy of the pointer. Nope. It makes a copy of the whole entire string. Like, the full thing. Every character. She's thorough. π
Then the vibes check out like this:
- If
stris already incb,critbit0_insertreturns1. - If
stris not incb, it gets inserted, andcritbit0_insertreturns2. - If there's a memory allocation failure on the way π,
critbit0_insertleavescbcompletely alone β like, doesn't touch it, doesn't look at it, nothing β and returns0.
β οΈ Note that cb is only left untouched in the allocation-failure case. That's the one where she just walks away. π
β RETURN VALUE β
Three possible moods, and she's serving exactly one of them:
2β the key was inserted (slay β¨)1β it was already incb0β memory allocation failure π
π SEE ALSO π
critbit0_contains(3)β for when you wanna check if the thing is in there without adding it, iykyk π₯
Okay that's literally the whole page, you ate that. This little legend came out under the name critbit0_insert(3), filed under the Library Functions Manual β so if you see critbit0_insert(3) floating around, that's just her, the same girl, same page. π Go forth and insert responsibly, bestie. π§β¨
π¦ where this page comes from
- alpine 3.24: libowfat-doc 0.34-r0 Β· GPL-2.0-only
- debian bookworm: libowfat-dev 0.32-4 Β· GPL-2.0-only
- debian trixie: libowfat-dev 0.32-5 Β· GPL-2.0-only
- nixos 26.05: libowfat 0.34
- nixpkgs unstable: libowfat 0.34
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- ubuntu noble: libowfat-dev 0.32-4.1build1 Β· GPL-2.0-only
- ubuntu questing: libowfat-dev 0.32-5
- ubuntu resolute: libowfat-dev 0.34-2 Β· GPL-2.0-only
- ubuntu stonking: libowfat-dev 0.34-2 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms