aboutsummaryrefslogtreecommitdiff
path: root/src/common/container.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2011-03-16 17:09:32 -0400
committerNick Mathewson <nickm@torproject.org>2011-03-16 17:09:32 -0400
commit57b954293e3880f3b39d2f0f0f7710250e8ffc5f (patch)
tree06800a08323c179e6e38292ebba543165b0fb22d /src/common/container.c
parent415caba967b9b470623ab29230b820b3470a91e6 (diff)
parent6617822b841e32d6339bac13c79dd5f2b566c3c6 (diff)
downloadtor-57b954293e3880f3b39d2f0f0f7710250e8ffc5f.tar
tor-57b954293e3880f3b39d2f0f0f7710250e8ffc5f.tar.gz
Merge remote-tracking branch 'origin/maint-0.2.2'
Trivial Conflicts in src/common/crypto.c src/or/main.h src/or/or.h
Diffstat (limited to 'src/common/container.c')
-rw-r--r--src/common/container.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/common/container.c b/src/common/container.c
index f4dc07024..bc61226cb 100644
--- a/src/common/container.c
+++ b/src/common/container.c
@@ -638,15 +638,27 @@ smartlist_uniq_strings(smartlist_t *sl)
* }
*/
-/* For a 1-indexed array, we would use LEFT_CHILD[x] = 2*x and RIGHT_CHILD[x]
- * = 2*x + 1. But this is C, so we have to adjust a little. */
+/** @{ */
+/** Functions to manipulate heap indices to find a node's parent and children.
+ *
+ * For a 1-indexed array, we would use LEFT_CHILD[x] = 2*x and RIGHT_CHILD[x]
+ * = 2*x + 1. But this is C, so we have to adjust a little. */
//#define LEFT_CHILD(i) ( ((i)+1)*2 - 1)
//#define RIGHT_CHILD(i) ( ((i)+1)*2 )
//#define PARENT(i) ( ((i)+1)/2 - 1)
#define LEFT_CHILD(i) ( 2*(i) + 1 )
#define RIGHT_CHILD(i) ( 2*(i) + 2 )
#define PARENT(i) ( ((i)-1) / 2 )
-
+/** }@ */
+
+/** @{ */
+/** Helper macros for heaps: Given a local variable <b>idx_field_offset</b>
+ * set to the offset of an integer index within the heap element structure,
+ * IDX_OF_ITEM(p) gives you the index of p, and IDXP(p) gives you a pointer to
+ * where p's index is stored. Given additionally a local smartlist <b>sl</b>,
+ * UPDATE_IDX(i) sets the index of the element at <b>i</b> to the correct
+ * value (that is, to <b>i</b>).
+ */
#define IDXP(p) ((int*)STRUCT_VAR_P(p, idx_field_offset))
#define UPDATE_IDX(i) do { \
@@ -655,6 +667,7 @@ smartlist_uniq_strings(smartlist_t *sl)
} while (0)
#define IDX_OF_ITEM(p) (*IDXP(p))
+/** @} */
/** Helper. <b>sl</b> may have at most one violation of the heap property:
* the item at <b>idx</b> may be greater than one or both of its children.