diff options
author | Nick Mathewson <nickm@torproject.org> | 2006-06-21 04:57:12 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2006-06-21 04:57:12 +0000 |
commit | e2697a62ac0633f44ca76b0906aaf6234084d128 (patch) | |
tree | 4de2844ef5971d3b1ebf4bf1cd7d4a54200c9104 /src/common/container.c | |
parent | 03bea739f8d473b3362a3f1b8b8bfe6222293238 (diff) | |
download | tor-e2697a62ac0633f44ca76b0906aaf6234084d128.tar tor-e2697a62ac0633f44ca76b0906aaf6234084d128.tar.gz |
When requesting or serving resources via fingerprint/digest, request and respond in-order, removing duplicates.
svn:r6673
Diffstat (limited to 'src/common/container.c')
-rw-r--r-- | src/common/container.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/common/container.c b/src/common/container.c index 06e810a14..94f7f84df 100644 --- a/src/common/container.c +++ b/src/common/container.c @@ -461,6 +461,20 @@ smartlist_sort_strings(smartlist_t *sl) smartlist_sort(sl, _compare_string_ptrs); } +/** Helper: compare two DIGEST_LEN digests. */ +static int +_compare_digests(const void **_a, const void **_b) +{ + return memcmp((const char*)*_a, (const char*)*_b, DIGEST_LEN); +} + +/** Sort the list of DIGEST_LEN-byte digests into ascending order. */ +void +smartlist_sort_digests(smartlist_t *sl) +{ + smartlist_sort(sl, _compare_string_ptrs); +} + #define DEFINE_MAP_STRUCTS(maptype, keydecl, prefix) \ typedef struct prefix ## entry_t { \ HT_ENTRY(prefix ## entry_t) node; \ |