---
name: "idr_for_each"
section: "9"
platform: "linux"
package: "linux-manual-4.9"
version: "4.9.228-1"
release: "Debian 9 (Stretch)"
platforms: ["linux"]
url: "https://new.carta.tech/idr_for_each"
---

# idr\_for\_each(9)

iterate through all stored pointers

## NAME

idr\_for\_each - iterate through all stored pointers

## SYNOPSIS

**int idr\_for\_each(struct idr \*** *idp***, int (\****fn***) (int id, void \*p, void \*data), void \*** *data***);**

## ARGUMENTS

*idp*

idr handle

*fn*

function to be called for each pointer

*data*

data passed back to callback function

## DESCRIPTION

Iterate over the pointers registered with the given idr. The callback function will be called for each pointer currently registered, passing the id, the pointer and the data pointer passed to this function. It is not safe to modify the idr tree while in the callback, so functions such as idr\_get\_new and idr\_remove are not allowed.

We check the return of *fn* each time. If it returns anything other than **0**, we break out and return that value.

The caller must serialize **idr\_for\_each** vs **idr\_get\_new** and **idr\_remove**.

## COPYRIGHT
