]> git.ozlabs.org Git - ccan/blobdiff - ccan/idtree/idtree.h
ccan: Correct some poor conventions in _info includes
[ccan] / ccan / idtree / idtree.h
index cc84a3a9a7e9b61069625c0d55616618fe66dab4..7e58aa56bac314672d475e9af6f757d1369a61fd 100644 (file)
@@ -1,3 +1,4 @@
+/* Licensed under GPLv2+ - see LICENSE file for details */
 #ifndef CCAN_IDTREE_H
 #define CCAN_IDTREE_H
 #include <stdbool.h>
  * Allocate an empty id tree.  You can free it with talloc_free().
  *
  * Example:
- *     #include <err.h>
- *
  *     static struct idtree *ids;
  *
- *     ...
+ *     static void init(void)
+ *     {
  *             ids = idtree_new(NULL);
  *             if (!ids)
  *                     err(1, "Failed to allocate idtree");
+ *     }
  */
 struct idtree *idtree_new(void *mem_ctx);
 
@@ -31,14 +32,14 @@ struct idtree *idtree_new(void *mem_ctx);
  * Example:
  *     struct foo {
  *             unsigned int id;
- *             ...
+ *             // ...
  *     };
  *
  *     // Create a new foo, assigning an id.
- *     struct foo *new_foo(void)
+ *     static struct foo *new_foo(void)
  *     {
  *             int id;
- *             foo = malloc(sizeof(*foo));
+ *             struct foo *foo = malloc(sizeof(*foo));
  *             if (!foo)
  *                     return NULL;
  *
@@ -62,17 +63,13 @@ int idtree_add(struct idtree *idtree, const void *ptr, int limit);
  *
  * Example:
  *     static int last_id = -1;
- *     struct foo {
- *             unsigned int id;
- *             ...
- *     };
  *
  *     // Create a new foo, assigning a consecutive id.
  *     // This maximizes the time before ids roll.
- *     struct foo *new_foo(void)
+ *     static struct foo *new_foo_inc_id(void)
  *     {
  *             int id;
- *             foo = malloc(sizeof(*foo));
+ *             struct foo *foo = malloc(sizeof(*foo));
  *             if (!foo)
  *                     return NULL;
  *
@@ -102,7 +99,7 @@ int idtree_add_above(struct idtree *idtree, const void *ptr,
  *
  * Example:
  *     // Look up a foo for a given ID.
- *     struct foo *find_foo(unsigned int id)
+ *     static struct foo *find_foo(unsigned int id)
  *     {
  *             return idtree_lookup(ids, id);
  *     }
@@ -117,10 +114,8 @@ void *idtree_lookup(const struct idtree *idtree, int id);
  * Returns false if the id was not in the tree.
  *
  * Example:
- *     #include <assert.h>
- *
  *     // Look up a foo for a given ID.
- *     void *free_foo(struct foo *foo)
+ *     static void free_foo(struct foo *foo)
  *     {
  *             bool exists = idtree_remove(ids, foo->id);
  *             assert(exists);