summaryrefslogtreecommitdiff
path: root/src/common/container.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2006-06-21 04:57:12 +0000
committerNick Mathewson <nickm@torproject.org>2006-06-21 04:57:12 +0000
commite2697a62ac0633f44ca76b0906aaf6234084d128 (patch)
tree4de2844ef5971d3b1ebf4bf1cd7d4a54200c9104 /src/common/container.c
parent03bea739f8d473b3362a3f1b8b8bfe6222293238 (diff)
downloadtor-e2697a62ac0633f44ca76b0906aaf6234084d128.tar.gz
tor-e2697a62ac0633f44ca76b0906aaf6234084d128.zip
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.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/common/container.c b/src/common/container.c
index 06e810a149..94f7f84df5 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; \