diff options
author | Nick Mathewson <nickm@torproject.org> | 2013-09-09 13:48:44 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2014-03-14 11:57:51 -0400 |
commit | 1a74360c2dd5c197e2dfc28b37961c77bb7792f1 (patch) | |
tree | d1e856ff67b9dcf2a97fabaaea5fc599566a62d6 /src/common/container.c | |
parent | 102bb1c04f5cb4fb3eae7f41f80660e47c64ceb6 (diff) | |
download | tor-1a74360c2dd5c197e2dfc28b37961c77bb7792f1.tar.gz tor-1a74360c2dd5c197e2dfc28b37961c77bb7792f1.zip |
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.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/common/container.c b/src/common/container.c index f489430ca4..b937d544fc 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]]. |