rb_find_add_cached(9)
π rb_find_add_cached(9) π
okay so bestie, welcome to rb_find_add_cached β this is from the Kernel API Manual and it's genuinely one of those little red-black tree functions that just gets it. the whole vibe is: find the equivalent @node in @tree, or just add @node if it's not there. boom. iconic. β¨
πΈ SYNOPSIS πΈ
struct rb_node * rb_find_add_cached (struct rb_node *node , struct
rb_root_cached *tree , int (*cmp)(const struct rb_node *new, const
struct rb_node *exist) );
like, look at that signature. it's giving main character energy fr fr. π
π ARGUMENTS π
nodeβ the node you're looking for, or the one you're about to insert. it's doing double duty and honestly? we love that for it. π«Άtreeβ the tree you're searching through / modifying. your little red-black kingdom πcmpβ the operator that defines the node order. it's the vibe check for your nodes, lowkey. it takesconst struct rb_node *newandconst struct rb_node *exist. π
π¦ DESCRIPTION π¦
so here's the whole tea β: it returns the rb_node that matches node β and if there's no match? it returns NULL and node gets inserted. no cap. that's the entire plot and it ate. π₯
lowkey the neat part: you don't have to check-then-insert yourself, the function handles the "not found, so add it" branch for you. highkey convenient. β¨
π SEE ALSO π
- Kernel file
./include/linux/rbtree.hπ rbtree_postorder_for_each_entry_safe(9)rb_add_cached(9)rb_add_linked(9)rb_add(9)rb_find_add(9)rb_find_add_rcu(9)rb_find(9)rb_find_rcu(9)rb_find_first(9)rb_next_match(9)rb_for_each(9)
the whole rb squad is here and they're all slaying in their own way π
k bye bestie, go touch some trees (red-black ones, obviously) π³β¨
source: ./include/linux Β· October 2026 Β· rb_find_add_cached(9) β mwah, catch you in the next manpage ππ
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms