idr_alloc(9)

idr_alloc9

Allocate new idr entry

Usage

int idr_alloc(struct idr * idr, void * ptr, int start, int end, gfp_t gfp_mask);

Arguments

idr

the (initialized) idr

ptr

pointer to be associated with the new id

start

the minimum id (inclusive)

end

the maximum id (exclusive, <= 0 for max)

gfp_mask

memory allocation flags

Overview

Allocate an id in [start, end) and associate it with ptr. If no ID is available in the specified range, returns -ENOSPC. On memory allocation failure, returns -ENOMEM.

Note that end is treated as max when <= 0. This is to always allow using start + N as end as long as N is inside integer range.

The user is responsible for exclusively synchronizing all operations which may modify idr. However, read-only accesses such as idr_find or iteration can be performed under RCU read lock provided the user destroys ptr in RCU-safe way after removal from idr.

Releases

2 releases since Debian 8 (Jessie); the text changed 1 time.

  1. 8
  2. 9

From linux-manual-4.9 4.9.228-1 in Debian 9 (Stretch). Parsed by carta from the page's man source.