6 * idtree - id allocation tree
8 * There are often cases where you want to provide an integer handle for
9 * some data, and easily map it back to another structure.
11 * idtree is an efficient implementation of an int->void * mapping, with
12 * assignment of the lowest available id number. It is from the Linux kernel
13 * via the Samba project.
16 * #include <ccan/idtree/idtree.h>
17 * #include <ccan/tal/tal.h>
21 * // Silly example which puts args in the idtree and retreives them
22 * int main(int argc, char *argv[])
24 * struct idtree *idtree = idtree_new(NULL);
27 * // This will return consecutive id numbers.
28 * for (i = 0; i < argc; i++) {
29 * printf("idtree_add('%s') -> id %i\n",
30 * argv[i], idtree_add(idtree, argv[i], -1));
32 * for (i = 0; i < argc; i++) {
33 * printf("id %i -> '%s'\n",
34 * i, (char *)idtree_lookup(idtree, i));
39 * License: GPL (v2 or any later version)
40 * Maintainer: Rusty Russell <rusty@rustcorp.com.au>
41 * Author: Jim Houston <jim.houston@ccur.com>
43 int main(int argc, char *argv[])
48 if (strcmp(argv[1], "depends") == 0) {