aboutsummaryrefslogtreecommitdiff
path: root/src/common/container.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2013-09-09 13:48:44 -0400
committerNick Mathewson <nickm@torproject.org>2014-03-14 11:57:51 -0400
commit1a74360c2dd5c197e2dfc28b37961c77bb7792f1 (patch)
treed1e856ff67b9dcf2a97fabaaea5fc599566a62d6 /src/common/container.c
parent102bb1c04f5cb4fb3eae7f41f80660e47c64ceb6 (diff)
downloadtor-1a74360c2dd5c197e2dfc28b37961c77bb7792f1.tar
tor-1a74360c2dd5c197e2dfc28b37961c77bb7792f1.tar.gz
Test code for implementation of faster circuit_unlink_all_from_channel
This contains the obvious implementation using the circuitmux data structure. It also runs the old (slow) algorithm and compares the results of the two to make sure that they're the same. Needs review and testing.
Diffstat (limited to 'src/common/container.c')
-rw-r--r--src/common/container.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/common/container.c b/src/common/container.c
index f489430ca..b937d544f 100644
--- a/src/common/container.c
+++ b/src/common/container.c
@@ -727,6 +727,26 @@ smartlist_uniq_strings(smartlist_t *sl)
smartlist_uniq(sl, compare_string_ptrs_, tor_free_);
}
+/** Helper: compare two pointers. */
+static int
+compare_ptrs_(const void **_a, const void **_b)
+{
+ const void *a = *_a, *b = *_b;
+ if (a<b)
+ return -1;
+ else if (a==b)
+ return 0;
+ else
+ return 1;
+}
+
+/** Sort <b>sl</b> in ascending order of the pointers it contains. */
+void
+smartlist_sort_pointers(smartlist_t *sl)
+{
+ smartlist_sort(sl, compare_ptrs_);
+}
+
/* Heap-based priority queue implementation for O(lg N) insert and remove.
* Recall that the heap property is that, for every index I, h[I] <
* H[LEFT_CHILD[I]] and h[I] < H[RIGHT_CHILD[I]].