rb_find_add_cached(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– 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 takes const struct rb_node *new and const 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 🌈

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