[or-cvs] When requesting or serving resources via fingerprint/digest...
Nick Mathewson
nickm at seul.org
Wed Jun 21 04:57:14 UTC 2006
Update of /home/or/cvsroot/tor/src/common
In directory moria:/home/nickm/src/tor/src/common
Modified Files:
container.c container.h
Log Message:
When requesting or serving resources via fingerprint/digest, request and respond in-order, removing duplicates.
Index: container.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/container.c,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -p -d -r1.59 -r1.60
--- container.c 18 Jun 2006 07:21:35 -0000 1.59
+++ container.c 21 Jun 2006 04:57:12 -0000 1.60
@@ -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; \
Index: container.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/container.h,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -p -d -r1.30 -r1.31
--- container.h 18 Jun 2006 07:21:35 -0000 1.30
+++ container.h 21 Jun 2006 04:57:12 -0000 1.31
@@ -72,6 +72,7 @@ void smartlist_insert(smartlist_t *sl, i
void smartlist_sort(smartlist_t *sl,
int (*compare)(const void **a, const void **b));
void smartlist_sort_strings(smartlist_t *sl);
+void smartlist_sort_digests(smartlist_t *sl);
void *smartlist_bsearch(smartlist_t *sl, const void *key,
int (*compare)(const void *key, const void **member));
More information about the tor-commits
mailing list