aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2009-02-18 06:14:47 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2009-02-18 06:14:47 +0000
commit235f1da99f71ada46f71401b995e0aa4a5651840 (patch)
tree46ddb9fd9728660014e89c275acc453223bcf05b /include
parentf9fa6f0e29ad0e2b74e10dcc2eed02d449a8a215 (diff)
Add example code for a heap traversal.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@176904 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'include')
-rw-r--r--include/asterisk/heap.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/include/asterisk/heap.h b/include/asterisk/heap.h
index 6f6e52b2d..8148fa5ba 100644
--- a/include/asterisk/heap.h
+++ b/include/asterisk/heap.h
@@ -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);