6 * idtree_new - create an idr_context
7 * @mem_ctx: talloc parent to allocate from (may be NULL).
9 * Allocate an empty id tree. You can free it with talloc_free().
11 struct idtree *idtree_new(void *mem_ctx);
14 * idtree_add - get lowest available id, and assign a pointer to it.
15 * @idtree: the tree to allocate from
16 * @ptr: the non-NULL pointer to associate with the id
17 * @limit: the maximum id to allocate (ie. INT_MAX means no limit).
19 * This returns a non-negative id number, or -1 if all are taken.
21 int idtree_add(struct idtree *idtree, const void *ptr, int limit);
24 * idtree_add_above - get lowest available id, starting at a given value.
25 * @idtree: the tree to allocate from
26 * @ptr: the non-NULL pointer to associate with the id
27 * @starting_id: the minimum id value to consider.
28 * @limit: the maximum id to allocate (ie. INT_MAX means no limit).
30 * This returns a non-negative id number, or -1 if all are taken.
32 int idtree_add_above(struct idtree *idtree, const void *ptr,
33 int starting_id, int limit);
36 * idtree_lookup - look up a given id
37 * @idtree: the tree to look in
38 * @id: the id to look up
40 * Returns NULL if the value is not found, otherwise the pointer value
41 * set with the idtree_add()/idtree_add_above().
43 void *idtree_lookup(const struct idtree *idtree, int id);
46 * idtree_remove - remove a given id.
47 * @idtree: the tree to remove from
48 * @id: the id to remove.
50 * Returns false if the id was not in the tree.
52 bool idtree_remove(struct idtree *idtree, int id);
53 #endif /* CCAN_IDTREE_H */