idr_destroy(9)
π idr_destroy β release all internal memory from an IDR
okay so bestie, this is idr_destroy(9) from the Kernel API Manual, and it's genuinely one of the cleanest little functions you'll ever meet β it's giving closure, literally π
β¨ SYNOPSIS β¨
void idr_destroy (struct idr *idr );
πΈ ARGUMENTS πΈ
idrβ the idr handle. that's it. that's the whole argument list. iconic behavior honestly π
π¦ DESCRIPTION π¦
so after this function gets called, the IDR is empty, and you can reuse it, or you can free the whole data structure that's holding it. either way is valid, no cap β¨
the typical clean-up sequence for objects stored in an idr tree goes like this, bestie, follow along:
- use
idr_for_eachto free all the objects β but only if necessary, okay? don't be out here freeing stuff you don't need to free π - then call
idr_destroyto free the memory that was used to keep track of those objects π§
like, first you clear out the actual stuff, then you toss the little organizational system that was holding it all together. main character clean-up arc, fr fr π«Ά
π SEE ALSO π
Kernel file ./lib/radix-tree.c β and the whole radix-tree friend group shows up too, plus one idr bestie:
radix_tree_find_next_bit(9)radix_tree_shrink(9)__radix_tree_create(9)radix_tree_insert(9)__radix_tree_lookup(9)radix_tree_lookup_slot(9)radix_tree_lookup(9)__radix_tree_replace(9)radix_tree_replace_slot(9)radix_tree_iter_replace(9)radix_tree_tag_set(9)radix_tree_tag_clear(9)radix_tree_iter_tag_clear(9)radix_tree_tag_get(9)radix_tree_next_chunk(9)radix_tree_gang_lookup(9)radix_tree_gang_lookup_tag(9)radix_tree_gang_lookup_tag_slot(9)radix_tree_iter_delete(9)radix_tree_delete_item(9)radix_tree_delete(9)radix_tree_tagged(9)idr_preload(9)
and that's the whole page, bestie π this little gem lives in ./lib and the version vibes are dated October 2026 β so yeah, future-proof and fabulous. slay, go free your IDR πβ¨
π¦ 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