__radix_tree_create(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’œ __radix_tree_create (9) β€” kernel API manual, bestie edition πŸŽ€

okay so this page is from the Kernel API Manual, and ngl it's a good one. we're creating slots in radix trees. it's giving data-structure main character energy ✨


🌸 NAME 🌸

__radix_tree_create β€” create a slot in a radix tree πŸ¦‹


✨ SYNOPSIS ✨

int __radix_tree_create (struct radix_tree_root *root , unsigned long
       index , struct radix_tree_node **nodep , void __rcu ***slotp );

no cap, that's the whole signature. four args, one int back. she's neat like that πŸ’…


πŸ“ ARGUMENTS πŸ“

  • root β€” the radix tree root, aka where the whole tree starts. the source of truth πŸ‘‘
  • index β€” the index key. this is which spot we're talking about, iykyk πŸ”‘
  • nodep β€” a return slot that hands you back the node 🫢
  • slotp β€” a return slot that hands you back the slot πŸ’–

(yes, both of those are out params. you're getting stuff back, not just shoving stuff in. love that for us)


🌈 DESCRIPTION 🌈

So the whole vibe: this function creates, if necessary, and returns the node and the slot for an item sitting at position index in the radix tree root. literally creating and handing back at the same time. versatile queen πŸ’…βœ¨

here's the fun part β€” and lowkey this is the important part β€” until there is more than one item in the tree, no nodes are allocated at all. instead, root->xa_head gets used as a direct slot rather than pointing to a node. and in that case, *nodep will be NULL. so if you're checking *nodep and it's NULL, that's not a bug, that's just the early-tree era 🧚 half of you is gonna be like "why is it NULL" and the answer is "because the tree is baby." periodt.

⚠️ okay warning time bestie: *nodep can legitimately be NULL in the single-item case described above. don't go dereferencing it without a vibe check, fr fr πŸ’€

Return value: -ENOMEM, or 0 for success. that's it, those are the options. 0 = slay, -ENOMEM = the allocator said no 😭


πŸ¦‹ SEE ALSO πŸ¦‹

Kernel file ./lib/radix-tree.c, plus the entire friend group β€” this list is long and we are not skipping anybody. every single one of these, in order, no cuts:

twenty-three entries. the whole squad got invited to the group chat πŸ’–


okay and finally, the sign-off 🌸: this one lives in ./lib (that's the source section), and it's dated October 2026. so like… future girl summer for the manpage πŸ’…πŸŽ€ go forth and create your slots, bestie, you're gonna ate this 🫢✨

πŸ“¦ where this page comes from