IDA DESCRIPTION(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– IDA description πŸ’–

okay bestie, this is the IDA description page from the Kernel API Manual, section 9 β€” and it’s giving tiny but mighty allocator energy. ✨

So the IDA is an ID allocator, and the big thing it does not do is give you the ability to associate an ID with a pointer. Because of that, it only needs to store one bit per ID β€” literally one bit β€” so it’s more space efficient than an IDR. Memory queen behavior, fr fr. πŸ‘‘

To use an IDA, define it using DEFINE_IDA (or embed a struct ida in a data structure, then initialise it using ida_init). To allocate a new ID, call ida_alloc, ida_alloc_min, ida_alloc_max or ida_alloc_range. To free an ID, call ida_free. Slay. πŸ’…

ida_destroy can be used to dispose of an IDA without needing to free the individual IDs in it. You can use ida_is_empty to find out whether the IDA has any IDs currently allocated. Cute and useful. πŸŽ€

The IDA handles its own locking. It is safe to call any of the IDA functions without synchronisation in your code. No cap β€” no extra lock choreography needed in your code. πŸ”’βœ¨

IDs are currently limited to the range [0-INT_MAX]. If this is an awkward limitation, it should be quite straightforward to raise the maximum.

πŸ¦‹ SEE ALSO πŸ¦‹

Kernel file ./lib/idr.c and the whole reference squad:

okay bye bestie πŸ’– mwah β€” source/version: ./lib; date: October 2026. 🫢🌸

πŸ“¦ where this page comes from