]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Merged revisions 176904 via svnmerge from
authorRussell Bryant <russell@russellbryant.com>
Wed, 18 Feb 2009 06:15:35 +0000 (06:15 +0000)
committerRussell Bryant <russell@russellbryant.com>
Wed, 18 Feb 2009 06:15:35 +0000 (06:15 +0000)
https://origsvn.digium.com/svn/asterisk/trunk

........
r176904 | russell | 2009-02-18 00:14:47 -0600 (Wed, 18 Feb 2009) | 2 lines

Add example code for a heap traversal.

........

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.1@176906 65c4cc65-6c06-0410-ace0-fbb531ad65f3

include/asterisk/heap.h

index 6f6e52b2dc2fcf827c6a36dd516259ecda9efc54..8148fa5ba2299c8f6fd3887da1a22d5f23b78710 100644 (file)
@@ -155,6 +155,28 @@ void *ast_heap_remove(struct ast_heap *h, void *elm);
  * \note If this function is being used in combination with ast_heap_size() for
  *       purposes of traversing the heap, the heap must be locked for the entire
  *       duration of the traversal.
+ *
+ * Example code for a traversal:
+ * \code
+ *
+ * struct ast_heap *h;
+ *
+ * ...
+ *
+ * size_t size, i;
+ * void *cur_obj;
+ *
+ * ast_heap_rdlock(h);
+ *
+ * size = ast_heap_size(h);
+ *
+ * for (i = 1; i <= size && (cur_obj = ast_heap_peek(h, i)); i++) {
+ *     ... Do stuff with cur_obj ...
+ * }
+ *
+ * ast_heap_unlock(h);
+ *
+ * \endcode
  */
 void *ast_heap_peek(struct ast_heap *h, unsigned int index);